home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / abstyles / btxabst.doc < prev    next >
Text File  |  1991-07-08  |  79KB  |  2,879 lines

  1. % BibTeX `adaptable' family
  2.     % version 1.10 derived by Hans-Hermann Bode (H2B), Osnabr\"uck, 
  3.     % (BitNet/EARN: HHBODE@DOSUNI1)
  4.     % from the `plain' family version 0.99b.
  5.     % The copying statement declared below extends to this file also with 
  6.     % the file names btxabst.doc, aplain.bst, aunsrt.bst, aalpha.bst, 
  7.     % aabbrv.bst, anotit.bst, and aunsnot.bst added.
  8. % BibTeX `plain' family
  9.         % version 0.99b for BibTeX versions 0.99a or later, LaTeX version 2.09.
  10.     % Copyright (C) 1985, all rights reserved.
  11.     % Copying of this file is authorized only if either
  12.     % (1) you make absolutely no changes to your copy, including name, or
  13.     % (2) if you do make changes, you name it something other than
  14.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  15.     % This restriction helps ensure that all standard styles are identical.
  16.     % The file btxbst.doc has the documentation for this style.
  17. % Please notify Oren Patashnik (PATASHNIK@SCORE.STANFORD.EDU) of any bugs in
  18. % these standard styles or in this documentation file.
  19. %
  20. % This is file btxbxt.doc; it helps document bibliography styles,
  21. % and is also a template file that you can use to make
  22. % several different style files, if you have access to a C preprocessor.
  23. % For example, the standard styles were made by doing something like
  24. %    cpp -P -DAPLAIN btxabst.doc aplain.txt
  25. %    cpp -P -DAUNSRT btxabst.doc aunsrt.txt
  26. %    cpp -P -DAALPHA btxabst.doc aalpha.txt
  27. %    cpp -P -DAABBRV btxabst.doc aabbrv.txt
  28. %    cpp -P -DANOTIT btxabst.doc anotit.txt
  29. %    cpp -P -DAUNSNOT btxabst.doc aunsnot.txt
  30. % and then renaming after removing unwanted comments and blank lines.
  31. % If you don't have access,
  32. % you can edit this file by hand to imitate the preprocessor,
  33. % with the following explanation of the C preprocessor constructs used here.
  34. %
  35. % The output of the preprocessor is the same as the input, except that certain
  36. % lines will be excluded (and some blank lines will be added).  The sequence
  37. %    #if VAR
  38. %        lines to be included when VAR is not zero
  39. %    #else
  40. %        lines to be included when VAR is zero
  41. %    #endif
  42. % (with the #-signs appearing in column 1) means that one set or the other of
  43. % the lines are to be included depending on the value of VAR.
  44. % The #else part is optional.  Comments can be added after #else and #endif.
  45. % Variables can be set by
  46. %    #define VAR value
  47. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  48. % to see if it has none.
  49. % Another #if form used in this file is #if !VAR, which includes the lines
  50. % after the #if only if VAR is zero.
  51. %
  52. % Convention: Use all uppercase identifiers for these preprocessor variables
  53. % so you can spot them easily
  54. %
  55. % The command line to the preprocessor should define one of APLAIN, AUNSRT, AALPHA
  56. % or AABBRV (though APLAIN will be used by default if none is given),
  57. % and the following lines will set various boolean variables to control the
  58. % various lines that are chosen from the rest of the file.
  59. % Each boolean variable should be set true (1) or false (0) in each style.
  60. % Here are the current variables, and their meanings:
  61. %    LAB_ALPH:    an alphabetic label is used (if false then a numeric
  62. %                label is used)
  63. %    SORTED:        the entries should be sorted by label (if nonnumeric)
  64. %                and other info, like authors (if false, then
  65. %                entries remain in order of occurrence)
  66. %    NAME_FULL:    the authors, editors, etc., get the full names as
  67. %                given in the bibliography file (if false, the first
  68. %                names become initials)
  69. %    ATIT_LOWER:    titles of non-"books" (e.g., articles) should be
  70. %                converted to lower-case, except the first letter or
  71. %                first letter after a colon
  72. %                (if false then they appear as in the database)
  73. %    MONTH_FULL:    months are spelled out in full (if false, then
  74. %                they're abbreviated); now used generally for 
  75. %                distinction between ``full'' and ``abbreviated'' 
  76. %                styles (H2B)
  77. %    JOUR_FULL:    macro journal names are spelled out in full
  78. %                (if false then they are abbreviated, currently
  79. %                as they appear in ACM publications); no more used 
  80. %                (H2B)
  81. %    NO_TITLE:    the titles of articles, incollections, inproceedings 
  82. %            and techreports are omitted, if there are other 
  83. %            informations to identify the work cited (added by H2B)
  84. %
  85. #ifndef AUNSRT
  86. #   ifndef AALPHA
  87. #    ifndef AABBRV
  88. #        ifndef ANOTIT
  89. #            ifndef AUNSNOT
  90. #                    define APLAIN 1
  91. #            endif
  92. #        endif
  93. #    endif
  94. #   endif
  95. #endif
  96. #ifdef APLAIN
  97. % aplain style (sorted numbers)
  98. #   define LAB_ALPH 0
  99. #   define SORTED 1
  100. #   define NAME_FULL 1
  101. #   define ATIT_LOWER 1
  102. #   define MONTH_FULL 1
  103. #   define JOUR_FULL 1
  104. #   define NO_TITLE 0
  105. #endif
  106. #ifdef AUNSRT
  107. % aunsrt style (unsorted numbers)
  108. #   define LAB_ALPH 0
  109. #   define SORTED 0
  110. #   define NAME_FULL 1
  111. #   define ATIT_LOWER 1
  112. #   define MONTH_FULL 1
  113. #   define JOUR_FULL 1
  114. #   define NO_TITLE 0
  115. #endif
  116. #ifdef AALPHA
  117. % aalpha style (sorted short alphabetics)
  118. #   define LAB_ALPH 1
  119. #   define SORTED 1
  120. #   define NAME_FULL 1
  121. #   define ATIT_LOWER 1
  122. #   define MONTH_FULL 1
  123. #   define JOUR_FULL 1
  124. #   define NO_TITLE 0
  125. #endif
  126. #ifdef AABBRV
  127. % aabbrv style (sorted numbers, with abbreviations)
  128. #   define LAB_ALPH 0
  129. #   define SORTED 1
  130. #   define NAME_FULL 0
  131. #   define ATIT_LOWER 1
  132. #   define MONTH_FULL 0
  133. #   define JOUR_FULL 0
  134. #   define NO_TITLE 0
  135. #endif
  136. #ifdef ANOTIT
  137. % anotit style (sorted numbers, with abbreviations, no article titles)
  138. #   define LAB_ALPH 0
  139. #   define SORTED 1
  140. #   define NAME_FULL 0
  141. #   define ATIT_LOWER 1
  142. #   define MONTH_FULL 0
  143. #   define JOUR_FULL 0
  144. #   define NO_TITLE 1
  145. #endif
  146. #ifdef AUNSNOT
  147. % aunsnot style (unsorted numbers, with abbreviations, no article titles)
  148. #   define LAB_ALPH 0
  149. #   define SORTED 0
  150. #   define NAME_FULL 0
  151. #   define ATIT_LOWER 1
  152. #   define MONTH_FULL 0
  153. #   define JOUR_FULL 0
  154. #   define NO_TITLE 1
  155. #endif
  156. %
  157. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  158. %    in "A Handbook for Scholars".  Book-like titles are italicized
  159. %    (emphasized) and non-book titles are converted to sentence
  160. %    capitilization (and not enclosed in quotes).
  161. %    This file outputs a \newblock between major blocks of an entry
  162. %    (the name \newblock is analogous to the names \newline and \newpage)
  163. %    so that the user can obtain an "open" format, which has a line break
  164. %    before each block and lines after the first are indented within blocks,
  165. %    by giving the optional \documentstyle argument `openbib';
  166. %    The default is the "closed" format---blocks runs together.
  167. %
  168. %   Citation alphabetic label format:
  169. %        [Knu73] for single author (or editor or key)
  170. %        [AHU83] (first letters of last names) for multiple authors
  171. %
  172. %   Citation label numberic format:
  173. %        [number]
  174. %
  175. %   Reference list ordering for sorted, alphabetic lables:
  176. %        alphabetical by citation label, then by author(s) or whatever
  177. %        passes for author in the absence of one, then by year,
  178. %        then title
  179. %
  180. %   Reference list ordering for sorted, numeric lables:
  181. %        alphabetical by author(s) or whatever passes
  182. %        for author in the absence of one, then by year, then title
  183. %
  184. %   Reference list ordering for unsorted:
  185. %        by the order cited in the text
  186. %
  187. %   History
  188. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  189. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  190. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik.
  191. %    2/17/85    (HWT)    Template file and other standard styles made.
  192. %    3/28/85    (OP)    First release, version 0.98b for BibTeX 0.98f.
  193. %    5/ 9/85    (OP)    Version 0.98c for BibTeX 0.98i:
  194. %            fixed Theoretical Computer Science macro name;
  195. %            fixed the format.vol.num.pages function.
  196. %    1/24/88    (OP)    Version 0.99a for BibTeX 0.99a, main changes:
  197. %            assignment operator (:=) arguments reversed;
  198. %            the preamble$ function outputs the database PREAMBLE;
  199. %            entry.max$ and global.max$ (built-in) variables replace
  200. %            entry.string.max and global.string.max functions;
  201. %            alphabetizing by year then title, not just title;
  202. %            many unnecessary ties removed; \it ==> \em;
  203. %            the `alpha' style uses a superscripted `+' instead of a
  204. %            `*' for unnamed names in constructing the label;
  205. %            the `abbrv' style now uses "Mar." and "Sept.";
  206. %            the functions calc.label and presort now look at just
  207. %            the fields they're supposed to;
  208. %            BOOKLET, MASTERSTHESIS, TECHREPORT use nonbook titles;
  209. %            INBOOK and INCOLLECTION take an optional type (e.g.
  210. %            type = "Section"), overriding the default "chapter";
  211. %            BOOK, INBOOK, INCOLLECTION, and PROCEEDINGS now allow
  212. %            either volume or number, not just volume;
  213. %            INCOLLECTION now allows an edition and series field;
  214. %            PROCEEDINGS and INPROCEEDINGS now use the address field
  215. %            to tell where a conference was held;
  216. %            INPROCEEDINGS and PROCEEDINGS now allow either volume
  217. %            or number, and also a series field;
  218. %            MASTERSTHESIS and PHDTHESIS accept types other than
  219. %            "Master's thesis" and "PhD thesis";
  220. %            UNPUBLISHED now outputs, in one block, note then date;
  221. %            MANUAL now prints out the organization in
  222. %            the first block if the author field is empty;
  223. %            MISC can't be empty---it requires some optional field.
  224. %    3/23/88    (OP)    Version 0.99b for BibTeX 0.99c---changed the three
  225. %                       erroneous occurrences of `cite ' to `cite$ '; this
  226. %                       change didn't affect the four standard styles, so the
  227. %                       0.99a versions of those styles are still current.
  228. %    5/11/91    (H2B)    Version 1.00 of the `b' style family by 
  229. %            Hans-Hermann Bode with the following changes and 
  230. %            extensions: renaming the styles, adding a `anotit' 
  231. %            style; adding an output.state named continue.sentence 
  232. %            and a new.clause function; setting author names in 
  233. %            small caps, putting booktitles in quotes rather than 
  234. %            to emphasize them, boldfacing volume numbers of 
  235. %            journals, including date specification in parentheses, 
  236. %            discarding macros for journal names.
  237. %    6/15/91    (H2B)    Version 1.10 of the `adaptable' style family (which 
  238. %            replaces the `b' style family) with adaptable 
  239. %            type styles, phrases, conjunctions etc., new macros 
  240. %            for edition numbers and ``chapter'' names and a new 
  241. %            `aunsnot' style.
  242. %
  243. % The ENTRY declaration
  244. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  245. %   but no fullauthor or editors fields because BibTeX does name handling.
  246. %   The annote field is commented out here because this family doesn't
  247. %   include an annotated bibliography style.  And in addition to the fields
  248. %   listed here, BibTeX has a built-in crossref field, explained later.
  249.  
  250. ENTRY
  251. % Fields:
  252.   { address
  253. %        Usually the address of a publisher or other type of organization.
  254. %        Put information in this field only if it helps the reader find the
  255. %        thing---for example you should omit the address of a major
  256. %        publisher entirely.  For a PROCEEDINGS or an INPROCEEDINGS,
  257. %        however, it's the address of the conference; for those two entry
  258. %        types, include the publisher's or organization's address, if
  259. %        necessary, in the publisher or organization field.
  260. %    annote
  261. %        Long annotation---for annotated bibliographies (begins sentence).
  262.     author
  263. %        Name(s) of author(s), in BibTeX name format.
  264.     booktitle
  265. %        Book title when the thing being referenced isn't the whole book.
  266. %        For book entries, the title field should be used instead.
  267.     chapter
  268. %        Chapter (or section or whatever) number.
  269.     edition
  270. %        Edition of a book---should be an ordinal (e.g., "Second").
  271.     editor
  272. %        Name(s) of editor(s), in BibTeX name format.
  273. %        If there is also an author field, then the editor field should be
  274. %        for the book or collection that the work appears in.
  275.     howpublished
  276. %         How something strange has been published (begins sentence).
  277.     institution
  278. %        Sponsoring institution of a technical report.
  279.     journal
  280. %        Journal name (macros are provided for many).
  281.     key
  282. %        Alphabetizing, labeling, and cross-referencing key
  283. %        (needed when an entry has no author or editor).
  284.     month
  285. %        Month (macros are provided).
  286.     note
  287. %        To help the reader find a reference (begins sentence).
  288.     number
  289. %        Number of a journal or technical report, or of a work in a series.
  290.     organization
  291. %        Organization sponsoring a conference (or publishing a manual); if
  292. %        the editor (or author) is empty, and if the organization produces
  293. %        an awkward label or cross reference, you should put appropriately
  294. %        condensed organization information in the key field as well.
  295.     pages
  296. %        Page number or numbers (use `--' to separate a range, use `+'
  297. %        to indicate pages following that don't form a simple range).
  298.     publisher
  299. %        Publisher name.
  300.     school
  301. %        School name (for theses).
  302.     series
  303. %        The name of a series or set of books.
  304. %        An individual book will will also have it's own title.
  305.     title
  306. %        The title of the thing you're referred to.
  307.     type
  308. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  309. %        the default "Technical Report"; or, similarly, the type of a
  310. %        thesis; or of a part of a book.
  311.     volume
  312. %        The volume number of a journal or multivolume work.
  313.     year
  314. %        The year should contain only numerals (technically, it should end
  315. %        with four numerals, after purification; doesn't a begin sentence).
  316.   }
  317. % There are no integer entry variables
  318.   {}
  319. % These string entry variables are used to form the citation label.
  320. % In a storage pinch, sort.label can be easily computed on the fly.
  321. #if LAB_ALPH
  322. #if SORTED
  323.   { label extra.label sort.label }
  324. #else !SORTED
  325. % It doesn't seem like a good idea to use an order-of-citation
  326. % reference list when using alphabetic labels, but when this happens
  327. % we do things a little differently
  328.   { label }
  329. #endif SORTED
  330. #else !LAB_ALPH
  331.   { label }
  332. #endif LAB_ALPH
  333.  
  334. % The following macros have to be defined by the user (e.g., with the 
  335. % expansions given below) for formatting of certain fields and to replace the 
  336. % constant built-in strings for phrases, conjunctions etc. This makes the 
  337. % BibTeX style files adaptable---a feature introduced by H2B.
  338. %
  339. % The type style of certain fields is determined by the \abtype command. The 
  340. % first parameter is a number, that denotes the field in question, namely:
  341. %   0    author and editor names,
  342. %   1    titles of books and series,
  343. %   2    journal titles,
  344. %   3    journal volumes,
  345. %   4    journal numbers, and
  346. %   5    dates.
  347. % The second parameter is the text to format. Hence, the type style macro 
  348. % could be something like:
  349. %   \def\abtype#1#2{%
  350. %     \ifcase#1{\sc#2}\or``#2''\or{\em#2\/}\or{\bf#2}\or(#2)\or(#2)\else#2\fi}
  351. % The \else clause returns the text unformatted, if the command is called with 
  352. % an undefined field number (which is not used in this file).
  353. %
  354. % Phrases are defined by the \abphrase command. The only parameter is a code 
  355. % for the phrase:
  356. %    0    conjunction between two or before the last name of a name list
  357. %    1    comes before the last conjunction of a name list
  358. %    2    replaces names of co-authors and co-editors (``et al.'')
  359. %    3    marks multiple editors
  360. %    4    marks a single editor
  361. %    5    ``of'' for a volume of a series or crossref
  362. %    6    ``in'' for a number in a series
  363. %    7    ``In'' for crossrefs to books, articles, etc.
  364. %    8    comes before a volume number, lower-case
  365. %    9    comes before a volume number, upper-case
  366. %   10    comes before a series number, lower-case
  367. %   11    comes before a series number, upper-case
  368. %   12    comes after an edition number
  369. %   13    comes before multiple page numbers
  370. %   14    comes before a single page number
  371. %   15    comes before a chapter number
  372. %   16    denotes a technical report
  373. %   17    denotes a master's thesis
  374. %   18    denotes a phd thesis
  375. % An appropriate definition of the phrases macro would be:
  376. %   \def\abphrase#1{%
  377. %     \ifcase#1{ and }\or{,}\or{ et~al.}\or{, editors}\or{, editor}\or%
  378. %       { of }\or{ in }\or{In }\or{volume}\or{Volume}\or{number}\or{Number}\or%
  379. %       { edition}\or{pages}\or{page}\or{chapter}\or%
  380. %       {Technical Report}\or{Master's thesis}\or{PhD thesis}\fi}
  381.  
  382. % Each entry function starts by calling output.bibitem, to write the
  383. % \bibitem and its arguments to the .BBL file.  Then the various fields
  384. % are formatted and printed by output or output.check.  Those functions
  385. % handle the writing of separators (commas, periods, \newblock's),
  386. % taking care not to do so when they are passed a null string.
  387. % Finally, fin.entry is called to add the final period and finish the
  388. % entry.
  389. %
  390. % A bibliographic reference is formatted into a number of `blocks':
  391. % in the open format, a block begins on a new line and subsequent
  392. % lines of the block are indented.  A block may contain more than
  393. % one sentence (well, not a grammatical sentence, but something to
  394. % be ended with a sentence ending period).  The entry functions should
  395. % call new.block whenever a block other than the first is about to be
  396. % started.  They should call new.sentence whenever a new sentence is
  397. % to be started.  The output functions will ensure that if two
  398. % new.sentence's occur without any non-null string being output between
  399. % them then there won't be two periods output.  Similarly for two
  400. % successive new.block's.
  401. %
  402. % The output routines don't write their argument immediately.
  403. % Instead, by convention, that argument is saved on the stack to be
  404. % output next time (when we'll know what separator needs to come
  405. % after it).  Meanwhile, the output routine has to pop the pending
  406. % output off the stack, append any needed separator, and write it.
  407. %
  408. % To tell which separator is needed, we maintain an output.state.
  409. % It will be one of these values:
  410. %    before.all        just after the \bibitem
  411. %    continue.sentence    in the middle of a sentence: blank---no 
  412. %                    comma---needed if more sentence is 
  413. %                    output (value added by H2B)
  414. %    mid.sentence        in the middle of a sentence: comma needed
  415. %                    if more sentence is output
  416. %    after.sentence        just after a sentence: period needed
  417. %    after.block        just after a block (and sentence):
  418. %                    period and \newblock needed.
  419. % Note: These styles don't use after.sentence.
  420. % This note doesn't apply really (H2B).
  421. %
  422. % VAR: output.state : INTEGER        -- state variable for output
  423. %
  424. % The output.nonnull function saves its argument (assumed to be nonnull)
  425. % on the stack, and writes the old saved value followed by any needed
  426. % separator.  The ordering of the tests is decreasing frequency of
  427. % occurrence.
  428. %
  429. % output.nonnull(s) ==
  430. %  BEGIN
  431. %    s := argument on stack
  432. %    if output.state = continue.sentence then    -- added by H2B
  433. %        write$(pop() * " ")            -- dto.
  434. %            -- "pop" isn't a function: just use stack top
  435. %    else
  436. %        if output.state = mid.sentence then
  437. %            write$(pop() * ", ")
  438. %        else
  439. %            if output.state = after.block then
  440. %            write$(add.period$(pop()))
  441. %            newline$
  442. %            write$("\newblock ")
  443. %            else
  444. %            if output.state = before.all then
  445. %                write$(pop())
  446. %            else        -- output.state should be after.sentence
  447. %                write$(add.period$(pop()) * " ")
  448. %            fi
  449. %            fi
  450. %        fi
  451. %        output.state := continue.sentence
  452. %    fi
  453. %    push s on stack
  454. %  END
  455. %
  456. % The output function calls output.nonnull if its argument is non-empty;
  457. % its argument may be a missing field (thus, not necessarily a string)
  458. %
  459. % output(s) ==
  460. %  BEGIN
  461. %    if not empty$(s) then output.nonnull(s)
  462. %    fi
  463. %  END
  464. %
  465. % The output.check function is the same as the output function except that, if
  466. % necessary, output.check warns the user that the t field shouldn't be empty
  467. % (this is because it probably won't be a good reference without the field;
  468. % the entry functions try to make the formatting look reasonable even when
  469. % such fields are empty).
  470. %
  471. % output.check(s,t) ==
  472. %  BEGIN
  473. %    if empty$(s) then
  474. %        warning$("empty " * t * " in " * cite$)
  475. %    else output.nonnull(s)
  476. %    fi
  477. %  END
  478. %
  479. % The output.bibitem function writes the \bibitem for the current entry
  480. % (the label should already have been set up), and sets up the separator
  481. % state for the output functions.  And, it leaves a string on the stack
  482. % as per the output convention.
  483. %
  484. % output.bibitem ==
  485. %  BEGIN
  486. %    newline$
  487. %    write$("\bibitem[")    % for alphabetic labels,
  488. %    write$(label)        % these three lines
  489. %    write$("]{")        % are used
  490. %    write$("\bibitem{")        % this line for numeric labels
  491. %    write$(cite$)
  492. %    write$("}")
  493. %    push "" on stack
  494. %    output.state := before.all
  495. %  END
  496. %
  497. % The fin.entry function finishes off an entry by adding a period to the
  498. % string remaining on the stack.  If the state is still before.all
  499. % then nothing was produced for this entry, so the result will look bad,
  500. % but the user deserves it. (We don't omit the whole entry because the
  501. % entry was cited, and a bibitem is needed to define the citation label.)
  502. %
  503. % fin.entry ==
  504. %  BEGIN
  505. %    write$(add.period$(pop()))
  506. %    newline$
  507. %  END
  508. %
  509. % The new.block function prepares for a new block to be output, and
  510. % new.sentence prepares for a new sentence.
  511. % Added by H2B was new.clause, that prepares for a new subordinate clause.
  512. %
  513. % new.block ==
  514. %  BEGIN
  515. %    if output.state <> before.all then
  516. %        output.state := after.block
  517. %    fi
  518. %  END
  519. %
  520. % new.sentence ==
  521. %  BEGIN
  522. %    if output.state <> after.block then
  523. %        if output.state <> before.all then
  524. %        output.state :=  after.sentence
  525. %        fi
  526. %    fi
  527. %  END
  528. %
  529. % new.clause ==
  530. %  BEGIN
  531. %    if output.state <> after.sentence then
  532. %        if output.state <> after.block then
  533. %          if output.state <> before.all then
  534. %            output.state :=  mid.sentence
  535. %          fi
  536. %        fi
  537. %    fi
  538. %  END
  539. %
  540.  
  541. INTEGERS { output.state before.all mid.sentence after.sentence after.block 
  542.            continue.sentence }
  543.  
  544. FUNCTION {init.state.consts}
  545. { #0 'before.all :=
  546.   #1 'mid.sentence :=
  547.   #2 'after.sentence :=
  548.   #3 'after.block :=
  549.   #4 'continue.sentence :=
  550. }
  551.  
  552. % the variables s and t are temporary string holders
  553.  
  554. STRINGS { s t }
  555.  
  556. FUNCTION {output.nonnull}
  557. { 's :=
  558.   output.state continue.sentence =
  559.     { " " * write$ }
  560.     { output.state mid.sentence =
  561.     { ", " * write$ }
  562.     { output.state after.block =
  563.         { add.period$ write$
  564.           newline$
  565.           "\newblock " write$
  566.         }
  567.         { output.state before.all =
  568.         'write$
  569.         { add.period$ " " * write$ }
  570.           if$
  571.         }
  572.       if$
  573.     }
  574.       if$
  575.       continue.sentence 'output.state :=
  576.     }
  577.   if$
  578.   s
  579. }
  580.  
  581. FUNCTION {output}
  582. { duplicate$ empty$
  583.     'pop$
  584.     'output.nonnull
  585.   if$
  586. }
  587.  
  588. FUNCTION {output.check}
  589. { 't :=
  590.   duplicate$ empty$
  591.     { pop$ "empty " t * " in " * cite$ * warning$ }
  592.     'output.nonnull
  593.   if$
  594. }
  595.  
  596. FUNCTION {output.bibitem}
  597. { newline$
  598. #if LAB_ALPH
  599.   "\bibitem[" write$
  600.   label write$
  601.   "]{" write$
  602. #else
  603.   "\bibitem{" write$
  604. #endif LAB_ALPH
  605.   cite$ write$
  606.   "}" write$
  607.   newline$
  608.   ""
  609.   before.all 'output.state :=
  610. }
  611.  
  612. % This function finishes all entries.
  613.  
  614. FUNCTION {fin.entry}
  615. { add.period$
  616.   write$
  617.   newline$
  618. }
  619.  
  620. FUNCTION {new.block}
  621. { output.state before.all =
  622.     'skip$
  623.     { after.block 'output.state := }
  624.   if$
  625. }
  626.  
  627. FUNCTION {new.sentence}
  628. { output.state after.block =
  629.     'skip$
  630.     { output.state before.all =
  631.     'skip$
  632.     { after.sentence 'output.state := }
  633.       if$
  634.     }
  635.   if$
  636. }
  637.  
  638. FUNCTION {new.clause}
  639. { output.state after.sentence =
  640.     'skip$
  641.     { output.state after.block =
  642.     'skip$
  643.     { output.state before.all =
  644.         'skip$
  645.         { mid.sentence 'output.state := }
  646.           if$
  647.     }
  648.       if$
  649.     }
  650.   if$
  651. }
  652.  
  653. % These three functions pop one or two (integer) arguments from the stack
  654. % and push a single one, either 0 or 1.
  655. % The 'skip$ in the `and' and `or' functions are used because
  656. % the corresponding if$ would be idempotent
  657.  
  658. FUNCTION {not}
  659. {   { #0 }
  660.     { #1 }
  661.   if$
  662. }
  663.  
  664. FUNCTION {and}
  665. {   'skip$
  666.     { pop$ #0 }
  667.   if$
  668. }
  669.  
  670. FUNCTION {or}
  671. {   { pop$ #1 }
  672.     'skip$
  673.   if$
  674. }
  675.  
  676. % Sometimes we begin a new block only if the block will be big enough.  The
  677. % new.block.checka function issues a new.block if its argument is nonempty;
  678. % new.block.checkb does the same if either of its TWO arguments is nonempty.
  679.  
  680. FUNCTION {new.block.checka}
  681. { empty$
  682.     'skip$
  683.     'new.block
  684.   if$
  685. }
  686.  
  687. FUNCTION {new.block.checkb}
  688. { empty$
  689.   swap$ empty$
  690.   and
  691.     'skip$
  692.     'new.block
  693.   if$
  694. }
  695.  
  696. % The new.sentence.check functions are analogous.
  697.  
  698. FUNCTION {new.sentence.checka}
  699. { empty$
  700.     'skip$
  701.     'new.sentence
  702.   if$
  703. }
  704.  
  705. FUNCTION {new.sentence.checkb}
  706. { empty$
  707.   swap$ empty$
  708.   and
  709.     'skip$
  710.     'new.sentence
  711.   if$
  712. }
  713.  
  714. % And the new.clause.check functions, which were added by H2B, also.
  715.  
  716. FUNCTION {new.clause.checka}
  717. { empty$
  718.     'skip$
  719.     'new.clause
  720.   if$
  721. }
  722.  
  723. FUNCTION {new.clause.checkb}
  724. { empty$
  725.   swap$ empty$
  726.   and
  727.     'skip$
  728.     'new.clause
  729.   if$
  730. }
  731.  
  732. % Here are some functions for formatting chunks of an entry.
  733. % By convention they either produce a string that can be followed by
  734. % a comma or period (using add.period$, so it is OK to end in a period),
  735. % or they produce the null string.
  736. %
  737. % A useful utility is the field.or.null function, which checks if the
  738. % argument is the result of pushing a `missing' field (one for which no
  739. % assignment was made when the current entry was read in from the database)
  740. % or the result of pushing a string having no non-white-space characters.
  741. % It returns the null string if so, otherwise it returns the field string.
  742. % Its main (but not only) purpose is to guarantee that what's left on the
  743. % stack is a string rather than a missing field.
  744. %
  745. % field.or.null(s) ==
  746. %  BEGIN
  747. %    if empty$(s) then return ""
  748. %    else return s
  749. %  END
  750. %
  751. % Another helper function is emphasize, which returns the argument emphazised,
  752. % if that is non-empty, otherwise it returns the null string.  Italic
  753. % corrections aren't used, so this function should be used when punctation
  754. % will follow the result. In contrast to the last sentence, now italic 
  755. % corrections are always used (H2B).
  756. %
  757. % emphasize(s) ==
  758. %  BEGIN
  759. %    if empty$(s) then return ""
  760. %    else return "{\em " * s * "\/}"
  761. %  END
  762. %
  763. % Similar to emphasize is capitalize, from which the argument comes out in 
  764. % small caps. This function was added by H2B.
  765. %
  766. % capitalize(s) ==
  767. %  BEGIN
  768. %    if empty$(s) then return ""
  769. %    else return "{\sc " * s * "}"
  770. %  END
  771. %
  772. % And here is another such function---added by H2B---, that returns a boldface 
  773. % string.
  774. %
  775. % boldface(s) ==
  776. %  BEGIN
  777. %    if empty$(s) then return ""
  778. %    else return "{\bf " * s * "}"
  779. %  END
  780. %
  781. % The function quote will put its argument string in quotes (added by H2B).
  782. %
  783. % quote(s) ==
  784. %  BEGIN
  785. %    if empty$(s) then return ""
  786. %    else return "``" * s * "''"
  787. %  END
  788. %
  789. % And parentheses includes it in parentheses (added by H2B).
  790. %
  791. % parentheses(s) ==
  792. %  BEGIN
  793. %    if empty$(s) then return ""
  794. %    else return "(" * s * ")"
  795. %  END
  796. %
  797. % The format.names function formats the argument (which should be in
  798. % BibTeX name format) into "First Von Last, Junior", separated by commas
  799. % and with an "and" before the last (but ending with "et~al." if the last
  800. % of multiple authors is "others").  This function's argument should always
  801. % contain at least one name.
  802. %
  803. % VAR: nameptr, namesleft, numnames: INTEGER
  804. % pseudoVAR: nameresult: STRING        (it's what's accumulated on the stack)
  805. %
  806. % format.names(s) ==
  807. %  BEGIN
  808. %    nameptr := 1
  809. %    numnames := num.names$(s)
  810. %    namesleft := numnames
  811. %    while namesleft > 0
  812. %      do
  813. %                % for full names:
  814. %        t := format.name$(s, nameptr, "{ff~}{vv~}{ll}{, jj}")
  815. %                % for abbreviated first names:
  816. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  817. %        if nameptr > 1 then
  818. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  819. %        else if numnames > 2
  820. %               then nameresult := nameresult * ","
  821. %             fi
  822. %             if t = "others"
  823. %               then nameresult := nameresult * " et~al."
  824. %               else nameresult := nameresult * " and " * t
  825. %             fi
  826. %        fi
  827. %        else nameresult := t
  828. %        fi
  829. %        nameptr := nameptr + 1
  830. %        namesleft := namesleft - 1
  831. %      od
  832. %    return nameresult
  833. %  END
  834. %
  835. % The format.authors function returns the result of format.names(author)
  836. % if the author is present, or else it returns the null string.
  837. % Capitalization of names added by H2B.
  838. %
  839. % format.authors ==
  840. %  BEGIN
  841. %    if empty$(author) then return ""
  842. %    else return capitalize(format.names(author))
  843. %    fi
  844. %  END
  845. %
  846. % Format.editors is like format.authors, but it uses the editor field,
  847. % and appends ", editor" or ", editors".
  848. % Capitalization of names added by H2B.
  849. %
  850. % format.editors ==
  851. %  BEGIN
  852. %    if empty$(editor) then return ""
  853. %    else
  854. %        if num.names$(editor) > 1 then
  855. %        return capitalize(format.names(editor)) * ", editors"
  856. %        else
  857. %        return capitalize(format.names(editor)) * ", editor"
  858. %        fi
  859. %    fi
  860. %  END
  861. %
  862. % Other formatting functions are similar, so no "comment version" will be
  863. % given for them.
  864. %
  865. % The `pop$' in this function gets rid of the duplicate `empty' value and
  866. % the `skip$' returns the duplicate field value
  867.  
  868. FUNCTION {field.or.null}
  869. { duplicate$ empty$
  870.     { pop$ "" }
  871.     'skip$
  872.   if$
  873. }
  874.  
  875. FUNCTION {emphasize}
  876. { duplicate$ empty$
  877.     { pop$ "" }
  878.     { "\abtype{2}{" swap$ * "}" * }    %H2B
  879.   if$
  880. }
  881.  
  882. FUNCTION {capitalize}
  883. { duplicate$ empty$
  884.     { pop$ "" }
  885.     { "\abtype{0}{" swap$ * "}" * }    %H2B
  886.   if$
  887. }
  888.  
  889. FUNCTION {boldface}
  890. { duplicate$ empty$
  891.     { pop$ "" }
  892.     { "\abtype{3}{" swap$ * "}" * }    %H2B
  893.   if$
  894. }
  895.  
  896. FUNCTION {quote}
  897. { duplicate$ empty$
  898.     { pop$ "" }
  899.     { "\abtype{1}{" swap$ * "}" * }    %H2B
  900.   if$
  901. }
  902.  
  903. FUNCTION {parentheses}
  904. { duplicate$ empty$
  905.     { pop$ "" }
  906.     { "\abtype{5}{" swap$ * "}" * }    %H2B
  907.   if$
  908. }
  909.  
  910. INTEGERS { nameptr namesleft numnames }
  911.  
  912. FUNCTION {format.names}
  913. { 's :=
  914.   #1 'nameptr :=
  915.   s num.names$ 'numnames :=
  916.   numnames 'namesleft :=
  917.     { namesleft #0 > }
  918. #if NAME_FULL
  919.     { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
  920. #else
  921.     { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
  922. #endif NAME_FULL
  923.       nameptr #1 >
  924.     { namesleft #1 >
  925.         { ", " * t * }
  926.         { numnames #2 >
  927.         { "\abphrase{1}" * }    %H2B
  928.         'skip$
  929.           if$
  930.           t "others" =
  931.         { "\abphrase{2}" * }        %H2B
  932.         { "\abphrase{0}" * t * }    %H2B
  933.           if$
  934.         }
  935.       if$
  936.     }
  937.     't
  938.       if$
  939.       nameptr #1 + 'nameptr :=
  940.       namesleft #1 - 'namesleft :=
  941.     }
  942.   while$
  943. }
  944.  
  945. FUNCTION {format.authors}
  946. { author empty$
  947.     { "" }
  948.     { author format.names capitalize }
  949.   if$
  950. }
  951.  
  952. FUNCTION {format.editors}
  953. { editor empty$
  954.     { "" }
  955.     { editor format.names capitalize
  956.       editor num.names$ #1 >
  957.     { "\abphrase{3}" * }    %H2B
  958.     { "\abphrase{4}" * }    %H2B
  959.       if$
  960.     }
  961.   if$
  962. }
  963.  
  964. % The format.title function is used for non-book-like titles.
  965. % For most styles we convert to lowercase (except for the very first letter,
  966. % and except for the first one after a colon (followed by whitespace)),
  967. % and hope the user has brace-surrounded words that need to stay capitilized;
  968. % for some styles, however, we leave it as it is in the database.
  969.  
  970. FUNCTION {format.title}
  971. { title empty$
  972.     { "" }
  973. #if ATIT_LOWER
  974.     { title "t" change.case$ }
  975. #else
  976.     'title
  977. #endif ATIT_LOWER
  978.   if$
  979. }
  980.  
  981. % By default, BibTeX sets the global integer variable global.max$ to the BibTeX
  982. % constant glob_str_size, the maximum length of a global string variable.
  983. % Analogously, BibTeX sets the global integer variable entry.max$ to
  984. % ent_str_size, the maximum length of an entry string variable.
  985. % The style designer may change these if necessary (but this is unlikely)
  986.  
  987. % The n.dashify function makes each single `-' in a string a double `--'
  988. % if it's not already
  989. %
  990. % pseudoVAR: pageresult: STRING        (it's what's accumulated on the stack)
  991. %
  992. % n.dashify(s) ==
  993. %  BEGIN
  994. %    t := s
  995. %    pageresult := ""
  996. %    while (not empty$(t))
  997. %      do
  998. %        if (first character of t = "-")
  999. %          then
  1000. %        if (next character isn't)
  1001. %          then
  1002. %            pageresult := pageresult * "--"
  1003. %            t := t with the "-" removed
  1004. %          else
  1005. %            while (first character of t = "-")
  1006. %              do
  1007. %            pageresult := pageresult * "-"
  1008. %            t := t with the "-" removed
  1009. %              od
  1010. %        fi
  1011. %          else
  1012. %        pageresult := pageresult * the first character
  1013. %        t := t with the first character removed
  1014. %        fi
  1015. %      od
  1016. %    return pageresult
  1017. %  END
  1018.  
  1019. FUNCTION {n.dashify}
  1020. { 't :=
  1021.   ""
  1022.     { t empty$ not }
  1023.     { t #1 #1 substring$ "-" =
  1024.     { t #1 #2 substring$ "--" = not
  1025.         { "--" *
  1026.           t #2 global.max$ substring$ 't :=
  1027.         }
  1028.         {   { t #1 #1 substring$ "-" = }
  1029.         { "-" *
  1030.           t #2 global.max$ substring$ 't :=
  1031.         }
  1032.           while$
  1033.         }
  1034.       if$
  1035.     }
  1036.     { t #1 #1 substring$ *
  1037.       t #2 global.max$ substring$ 't :=
  1038.     }
  1039.       if$
  1040.     }
  1041.   while$
  1042. }
  1043.  
  1044. % The format.date function is for the month and year, but we give a warning if
  1045. % there's an empty year but the month is there, and we return the empty string
  1046. % if they're both empty.
  1047. % The resulting string is enclosed in parentheses (H2B).
  1048.  
  1049. FUNCTION {format.date}
  1050. { year empty$
  1051.     { month empty$
  1052.     { "" }
  1053.     { "there's a month but no year in " cite$ * warning$
  1054.       month parentheses
  1055.     }
  1056.       if$
  1057.     }
  1058.     { month empty$
  1059.     { year parentheses }
  1060.     { month " " * year * parentheses }
  1061.       if$
  1062.     }
  1063.   if$
  1064. }
  1065.  
  1066. % The format.btitle is for formatting the title field when it is a book-like
  1067. % entry---the style used here keeps it in uppers-and-lowers and emphasizes it.
  1068. % The emphasis will be done by quotation marks (H2B).
  1069.  
  1070. FUNCTION {format.btitle}
  1071. { title quote
  1072. }
  1073.  
  1074. % For several functions we'll need to connect two strings with a
  1075. % tie (~) if the second one isn't very long (fewer than 3 characters).
  1076. % The tie.or.space.connect function does that.  It concatenates the two
  1077. % strings on top of the stack, along with either a tie or space between
  1078. % them, and puts this concatenation back onto the stack:
  1079. %
  1080. % tie.or.space.connect(str1,str2) ==
  1081. %    BEGIN
  1082. %    if text.length$(str2) < 3
  1083. %      then return the concatenation of str1, "~", and str2
  1084. %      else return the concatenation of str1, " ", and str2
  1085. %    END
  1086.  
  1087. FUNCTION {tie.or.space.connect}
  1088. { duplicate$ text.length$ #3 <
  1089.     { "~" }
  1090.     { " " }
  1091.   if$
  1092.   swap$ * *
  1093. }
  1094.  
  1095. % The either.or.check function complains if both fields or an either-or pair
  1096. % are nonempty.
  1097. %
  1098. % either.or.check(t,s) ==
  1099. %  BEGIN
  1100. %    if empty$(s) then
  1101. %        warning$(can't use both " * t * " fields in " * cite$)
  1102. %    fi
  1103. %  END
  1104.  
  1105. FUNCTION {either.or.check}
  1106. { empty$
  1107.     'pop$
  1108.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  1109.   if$
  1110. }
  1111.  
  1112. % The format.bvolume function is for formatting the volume and perhaps
  1113. % series name of a multivolume work.  If both a volume and a series field
  1114. % are there, we assume the series field is the title of the whole multivolume
  1115. % work (the title field should be the title of the thing being referred to),
  1116. % and we add an "of <series>".  This function is called in mid-sentence.
  1117. % The emphasis will be done by quotation marks (H2B).
  1118.  
  1119. FUNCTION {format.bvolume}
  1120. { volume empty$
  1121.     { "" }
  1122.     { "\abphrase{8}" volume tie.or.space.connect    %H2B
  1123.       series empty$
  1124.     'skip$
  1125.     { "\abphrase{5}" * series quote * }    %H2B
  1126.       if$
  1127.       "volume and number" number either.or.check
  1128.     }
  1129.   if$
  1130. }
  1131.  
  1132. % The format.number.series function is for formatting the series name
  1133. % and perhaps number of a work in a series.  This function is similar to
  1134. % format.bvolume, although for this one the series must exist (and the
  1135. % volume must not exist).  If the number field is empty we output either
  1136. % the series field unchanged if it exists or else the null string.
  1137. % If both the number and series fields are there we assume the series field
  1138. % gives the name of the whole series (the title field should be the title
  1139. % of the work being one referred to), and we add an "in <series>".
  1140. % We capitilize Number when this function is used at the beginning of a block.
  1141. % The latter applies if output.state is mid.sentence or continue.sentence 
  1142. % (H2B).
  1143.  
  1144. FUNCTION {format.number.series}
  1145. { volume empty$
  1146.     { number empty$
  1147.     { series field.or.null }
  1148.     { output.state mid.sentence = output.state continue.sentence = or
  1149.         { "\abphrase{10}" }    %H2B
  1150.         { "\abphrase{11}" }    %H2B
  1151.       if$
  1152.       number tie.or.space.connect
  1153.       series empty$
  1154.         { "there's a number but no series in " cite$ * warning$ }
  1155.         { "\abphrase{6}" * series * }    %H2B
  1156.       if$
  1157.     }
  1158.       if$
  1159.     }
  1160.     { "" }
  1161.   if$
  1162. }
  1163.  
  1164. % The format.edition function appends " edition" to the edition, if present.
  1165. % We lowercase the edition (it should be something like "Third"), because
  1166. % this doesn't start a sentence.
  1167. % The latter applies if output.state is mid.sentence or continue.sentence 
  1168. % (H2B).
  1169.  
  1170. FUNCTION {format.edition}
  1171. { edition empty$
  1172.     { "" }
  1173.     { output.state mid.sentence = output.state continue.sentence = or
  1174.     { edition "l" change.case$ "\abphrase{12}" * }    %H2B
  1175.     { edition "t" change.case$ "\abphrase{12}" * }    %H2B
  1176.       if$
  1177.     }
  1178.   if$
  1179. }
  1180.  
  1181. % The format.pages function is used for formatting a page range in a book
  1182. % (and in rare circumstances, an article).
  1183. %
  1184. % The multi.page.check function examines the page field for a "-" or "," or "+"
  1185. % so that format.pages can use "page" instead of "pages" if none exists.
  1186. % Note: global.max$ here means "take the rest of the string"
  1187. %
  1188. % VAR: multiresult: INTEGER    (actually, a boolean)
  1189. %
  1190. % multi.page.check(s) ==
  1191. %  BEGIN
  1192. %    t := s
  1193. %    multiresult := false
  1194. %    while ((not multiresult) and (not empty$(t)))
  1195. %      do
  1196. %        if (first character of t = "-" or "," or "+")
  1197. %          then multiresult := true
  1198. %          else t := t with the first character removed
  1199. %        fi
  1200. %      od
  1201. %    return multiresult
  1202. %  END
  1203.  
  1204. INTEGERS { multiresult }
  1205.  
  1206. FUNCTION {multi.page.check}
  1207. { 't :=
  1208.   #0 'multiresult :=
  1209.     { multiresult not
  1210.       t empty$ not
  1211.       and
  1212.     }
  1213.     { t #1 #1 substring$
  1214.       duplicate$ "-" =
  1215.       swap$ duplicate$ "," =
  1216.       swap$ "+" =
  1217.       or or
  1218.     { #1 'multiresult := }
  1219.     { t #2 global.max$ substring$ 't := }
  1220.       if$
  1221.     }
  1222.   while$
  1223.   multiresult
  1224. }
  1225.  
  1226. % This function doesn't begin a sentence so "pages" isn't capitalized.
  1227. % Other functions that use this should keep that in mind.
  1228.  
  1229. FUNCTION {format.pages}
  1230. { pages empty$
  1231.     { "" }
  1232.     { pages multi.page.check
  1233.     { "\abphrase{13}" pages n.dashify tie.or.space.connect }    %H2B
  1234.     { "\abphrase{14}" pages tie.or.space.connect }            %H2B
  1235.       if$
  1236.     }
  1237.   if$
  1238. }
  1239.  
  1240. % The format.vol.num.pages function is for the volume, number, and page range
  1241. % of a journal article.  We use the format:  vol(number):pages, with some
  1242. % variations for empty fields.  This doesn't begin a sentence.
  1243. % The format was changed to `vol(number), pages', where the `vol' comes out in 
  1244. % boldface, by H2B.
  1245.  
  1246. FUNCTION {format.vol.num.pages}
  1247. { volume field.or.null boldface
  1248.   number empty$
  1249.     'skip$
  1250.     { "\abtype{4}{" number * "}" * *    %H2B
  1251.       volume empty$
  1252.     { "there's a number but no volume in " cite$ * warning$ }
  1253.     'skip$
  1254.       if$
  1255.     }
  1256.   if$
  1257.   pages empty$
  1258.     'skip$
  1259.     { duplicate$ empty$
  1260.     { pop$ format.pages }
  1261.     { ", " * pages n.dashify * }
  1262.       if$
  1263.     }
  1264.   if$
  1265. }
  1266.  
  1267.  
  1268. % The format.chapter.pages, if the chapter is present, puts whatever is in the
  1269. % type field (or else "chapter" if type is empty) in front of a chapter number.
  1270. % It then appends the pages, if present.  This doesn't begin a sentence.
  1271.  
  1272. FUNCTION {format.chapter.pages}
  1273. { chapter empty$
  1274.     'format.pages
  1275.     { type empty$
  1276.     { "\abphrase{15}" }    %H2B
  1277.     { type "l" change.case$ }
  1278.       if$
  1279.       chapter tie.or.space.connect
  1280.       pages empty$
  1281.     'skip$
  1282.     { ", " * format.pages * }
  1283.       if$
  1284.     }
  1285.   if$
  1286. }
  1287.  
  1288. % The format.in.ed.booktitle function is used for starting out a sentence
  1289. % that begins "In <booktitle>", putting an editor before the title if one
  1290. % exists.
  1291. % The emphasis will be done by quotation marks (H2B).
  1292.  
  1293. FUNCTION {format.in.ed.booktitle}
  1294. { booktitle empty$
  1295.     { "" }
  1296.     { editor empty$
  1297.     { "\abphrase{7}" booktitle quote * }                %H2B
  1298.     { "\abphrase{7}" format.editors * ", " * booktitle quote * }    %H2B
  1299.       if$
  1300.     }
  1301.   if$
  1302. }
  1303.  
  1304. % The function empty.misc.check complains if all six fields are empty, and
  1305. % if there's been no sorting or alphabetic-label complaint.
  1306.  
  1307. FUNCTION {empty.misc.check}
  1308. { author empty$ title empty$ howpublished empty$
  1309.   month empty$ year empty$ note empty$
  1310.   and and and and and
  1311. #if SORTED
  1312.   key empty$ not and
  1313. #else !SORTED
  1314. #if LAB_ALPH
  1315.   key empty$ not and
  1316. #endif LAB_ALPH
  1317. #endif SORTED
  1318.     { "all relevant fields are empty in " cite$ * warning$ }
  1319.     'skip$
  1320.   if$
  1321. }
  1322.  
  1323. % The function format.thesis.type returns either the (case-changed) type field,
  1324. % if it is defined, or else the default string already on the stack
  1325. % (like "Master's thesis" or "PhD thesis").
  1326.  
  1327. FUNCTION {format.thesis.type}
  1328. { type empty$
  1329.     'skip$
  1330.     { pop$
  1331.       type "t" change.case$
  1332.     }
  1333.   if$
  1334. }
  1335.  
  1336. % The function format.tr.number makes a string starting with "Technical Report"
  1337. % (or type, if that field is defined), followed by the number if there is one;
  1338. % it returns the starting part (with a case change) even if there is no number.
  1339. % This is used at the beginning of a sentence.
  1340.  
  1341. FUNCTION {format.tr.number}
  1342. { type empty$
  1343.     { "\abphrase{16}" }    %H2B
  1344.     'type
  1345.   if$
  1346.   number empty$
  1347.     { "t" change.case$ }
  1348.     { number tie.or.space.connect }
  1349.   if$
  1350. }
  1351.  
  1352. % Now come the cross-referencing functions (these are invoked because
  1353. % one entry in the database file(s) cross-references another, by giving
  1354. % the other entry's database key in a `crossref' field).  This feature
  1355. % allows one or more titled things that are part of a larger titled
  1356. % thing to cross-reference the larger thing.  These styles allow for
  1357. % five posibilities: (1) an ARTICLE may cross-reference an ARTICLE;
  1358. % (2) a BOOK, (3) INBOOK, or (4) INCOLLECTION may cross-reference a BOOK;
  1359. % or (5) an INPROCEEDINGS may cross-reference a PROCEEDINGS.
  1360. % Each of these is explained in more detail later.
  1361. %
  1362. % An ARTICLE entry type may cross reference another ARTICLE (this is
  1363. % intended for when an entire journal is devoted to a single topic---
  1364. % but since there is no JOURNAL entry type, the journal, too, should be
  1365. % classified as an ARTICLE but without the author and title fields).
  1366. % This will result in two warning messages for the journal's entry
  1367. % if it's included in the reference list, but such is life.
  1368. % In the original true function the emphasis with italic correction had been 
  1369. % made by inserting the necessary TeX control sequences directly; this is 
  1370. % substituted by a call to emphasize (H2B).
  1371. %
  1372. % format.article.crossref ==
  1373. %  BEGIN
  1374. %    if empty$(key) then
  1375. %        if empty$(journal) then
  1376. %        warning$("need key or journal for " * cite$ *
  1377. %                        " to crossref " * crossref)
  1378. %        return(" \cite{" * crossref * "}")
  1379. %        else
  1380. %        return("In " * emphazise.correct (journal) *
  1381. %                        " \cite{" * crossref * "}")
  1382. %        fi
  1383. %    else
  1384. %        return("In " * key * " \cite{" * crossref * "}")
  1385. %    fi
  1386. %  END
  1387. %
  1388. % The other cross-referencing functions are similar, so no "comment version"
  1389. % will be given for them.
  1390.  
  1391. FUNCTION {format.article.crossref}
  1392. { key empty$
  1393.     { journal empty$
  1394.     { "need key or journal for " cite$ * " to crossref " * crossref *
  1395.       warning$
  1396.       ""
  1397.     }
  1398.     { "\abphrase{7}" journal emphasize * }    %H2B
  1399.       if$
  1400.     }
  1401.     { "\abphrase{7}" key * }    %H2B
  1402.   if$
  1403.   " \cite{" * crossref * "}" *
  1404. }
  1405.  
  1406. % We use just the last names of editors for a cross reference: either
  1407. % "editor", or "editor1 and editor2", or "editor1 et~al." depending on
  1408. % whether there are one, or two, or more than two editors.
  1409.  
  1410. FUNCTION {format.crossref.editor}
  1411. { editor #1 "{vv~}{ll}" format.name$
  1412.   editor num.names$ duplicate$
  1413.   #2 >
  1414.     { pop$ "\abphrase{2}" * }    %H2B
  1415.     { #2 <
  1416.     'skip$
  1417.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1418.         { "\abphrase{2}" * }                     %H2B
  1419.         { "\abphrase{0}" * editor #2 "{vv~}{ll}" format.name$ * } %H2B
  1420.       if$
  1421.     }
  1422.       if$
  1423.     }
  1424.   if$
  1425. }
  1426.  
  1427. % A BOOK (or INBOOK) entry type (assumed to be for a single volume in a
  1428. % multivolume work) may cross reference another BOOK (the entire multivolume).
  1429. % Usually there will be an editor, in which case we use that to construct the
  1430. % cross reference; otherwise we use a nonempty key field or else the series
  1431. % field (since the series gives the title of the multivolume work).
  1432. % The series title is enclosed in quotes rather than emphasized (H2B).
  1433.  
  1434. FUNCTION {format.book.crossref}
  1435. { volume empty$
  1436.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  1437.       "\abphrase{7}"                %H2B
  1438.     }
  1439.     { "\abphrase{9}" volume tie.or.space.connect    %H2B
  1440.       "\abphrase{5}" *                %H2B
  1441.     }
  1442.   if$
  1443.   editor empty$
  1444.   editor field.or.null author field.or.null =
  1445.   or
  1446.     { key empty$
  1447.     { series empty$
  1448.         { "need editor, key, or series for " cite$ * " to crossref " *
  1449.           crossref * warning$
  1450.           "" *
  1451.         }
  1452.         { series quote * }
  1453.       if$
  1454.     }
  1455.     { key * }
  1456.       if$
  1457.     }
  1458.     { format.crossref.editor * }
  1459.   if$
  1460.   " \cite{" * crossref * "}" *
  1461. }
  1462.  
  1463. % An INCOLLECTION entry type may cross reference a BOOK (assumed to be the
  1464. % collection), or an INPROCEEDINGS may cross reference a PROCEEDINGS.
  1465. % Often there will be an editor, in which case we use that to construct
  1466. % the cross reference; otherwise we use a nonempty key field or else
  1467. % the booktitle field (which gives the cross-referenced work's title).
  1468. % The booktitle is enclosed in quotes rather than emphasized (H2B).
  1469.  
  1470. FUNCTION {format.incoll.inproc.crossref}
  1471. { editor empty$
  1472.   editor field.or.null author field.or.null =
  1473.   or
  1474.     { key empty$
  1475.     { booktitle empty$
  1476.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  1477.           crossref * warning$
  1478.           ""
  1479.         }
  1480.         { "\abphrase{7}" booktitle quote * }    %H2B
  1481.       if$
  1482.     }
  1483.     { "\abphrase{7}" key * }    %H2B
  1484.       if$
  1485.     }
  1486.     { "\abphrase{7}" format.crossref.editor * }    %H2B
  1487.   if$
  1488.   " \cite{" * crossref * "}" *
  1489. }
  1490.  
  1491. % Now we define the type functions for all entry types that may appear
  1492. % in the .BIB file---e.g., functions like `article' and `book'.  These
  1493. % are the routines that actually generate the .BBL-file output for
  1494. % the entry.  These must all precede the READ command.  In addition, the
  1495. % style designer should have a function `default.type' for unknown types.
  1496. % Note: The fields (within each list) are listed in order of appearance,
  1497. % except as described for an `inbook' or a `proceedings'.
  1498. %
  1499. % The article function is for an article in a journal.  An article may
  1500. % CROSSREF another article.
  1501. %    Required fields: author, title, journal, year
  1502. %    Optional fields: volume, number, pages, month, note
  1503. %
  1504. % article ==
  1505. %  BEGIN
  1506. %    output.bibitem
  1507. %    output.check(format.authors,"author")
  1508. %    new.block
  1509. %    output.check(format.title,"title")    % omitted if NO_TITLE (H2B)
  1510. %    new.block                % dto.
  1511. %    if missing$(crossref) then
  1512. %        output.check(emphasize(journal),"journal")
  1513. %                    % italic correction added (H2B)
  1514. %        output(format.vol.num.pages)
  1515. %        output.check(format.date,"year")
  1516. %       else
  1517. %        output.nonnull(format.article.crossref)
  1518. %        new.clause                % added by H2B
  1519. %        output(format.pages)
  1520. %    fi
  1521. %    new.block
  1522. %    output(note)
  1523. %    fin.entry
  1524. %  END
  1525. %
  1526. % The book function is for a whole book.  A book may CROSSREF another book.
  1527. %    Required fields: author or editor, title, publisher, year
  1528. %    Optional fields: volume or number, series, address, edition, month,
  1529. %            note
  1530. %
  1531. % book ==
  1532. %  BEGIN
  1533. %    if empty$(author) then output.check(format.editors,"author and editor")
  1534. %    else    output.check(format.authors,"author")
  1535. %        if missing$(crossref) then
  1536. %            either.or.check("author and editor",editor)
  1537. %        fi
  1538. %    fi
  1539. %    new.block
  1540. %    output.check(format.btitle,"title")
  1541. %    if missing$(crossref) then
  1542. %        new.clause                % added by H2B
  1543. %        output(format.bvolume)
  1544. %        new.block
  1545. %        output(format.number.series)
  1546. %        new.sentence
  1547. %        output.check(publisher,"publisher")
  1548. %        new.clause.checka(address)        % added by H2B
  1549. %        output(address)
  1550. %       else
  1551. %        new.block
  1552. %        output.nonnull(format.book.crossref)
  1553. %    fi
  1554. %       edition new.clause.checka        % added by H2B
  1555. %    output(format.edition)
  1556. %    output.check(format.date,"year")
  1557. %    new.block
  1558. %    output(note)
  1559. %    fin.entry
  1560. %  END
  1561. %
  1562. % The other entry functions are all quite similar, so no "comment version"
  1563. % will be given for them.
  1564.  
  1565. FUNCTION {article}
  1566. { output.bibitem
  1567.   format.authors "author" output.check
  1568.   new.block
  1569. #if !NO_TITLE
  1570.   format.title "title" output.check
  1571.   new.block
  1572. #endif
  1573.   crossref missing$
  1574.     { journal emphasize "journal" output.check
  1575.       format.vol.num.pages output
  1576.       format.date "year" output.check
  1577.     }
  1578.     { format.article.crossref output.nonnull
  1579.       new.clause
  1580.       format.pages output
  1581.     }
  1582.   if$
  1583.   new.block
  1584.   note output
  1585.   fin.entry
  1586. }
  1587.  
  1588. FUNCTION {book}
  1589. { output.bibitem
  1590.   author empty$
  1591.     { format.editors "author and editor" output.check }
  1592.     { format.authors output.nonnull
  1593.       crossref missing$
  1594.     { "author and editor" editor either.or.check }
  1595.     'skip$
  1596.       if$
  1597.     }
  1598.   if$
  1599.   new.block
  1600.   format.btitle "title" output.check
  1601.   crossref missing$
  1602.     { new.clause
  1603.       format.bvolume output
  1604.       new.block
  1605.       format.number.series output
  1606.       new.sentence
  1607.       publisher "publisher" output.check
  1608.       address new.clause.checka
  1609.       address output
  1610.     }
  1611.     { new.block
  1612.       format.book.crossref output.nonnull
  1613.     }
  1614.   if$
  1615.   edition new.clause.checka
  1616.   format.edition output
  1617.   format.date "year" output.check
  1618.   new.block
  1619.   note output
  1620.   fin.entry
  1621. }
  1622.  
  1623. % A booklet is a bound thing without a publisher or sponsoring institution.
  1624. %    Required: title
  1625. %    Optional: author, howpublished, address, month, year, note
  1626.  
  1627. FUNCTION {booklet}
  1628. { output.bibitem
  1629.   format.authors output
  1630.   new.block
  1631.   format.title "title" output.check
  1632.   howpublished address new.block.checkb
  1633.   howpublished output
  1634.   address new.clause.checka
  1635.   address output
  1636.   format.date output
  1637.   new.block
  1638.   note output
  1639.   fin.entry
  1640. }
  1641.  
  1642. % For the conference entry type, see inproceedings.
  1643.  
  1644. % An inbook is a piece of a book: either a chapter and/or a page range.
  1645. % It may CROSSREF a book.  If there's no volume field, the type field
  1646. % will come before number and series.
  1647. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1648. %    Optional: volume or number, series, type, address, edition, month, note
  1649.  
  1650. FUNCTION {inbook}
  1651. { output.bibitem
  1652.   author empty$
  1653.     { format.editors "author and editor" output.check }
  1654.     { format.authors output.nonnull
  1655.       crossref missing$
  1656.     { "author and editor" editor either.or.check }
  1657.     'skip$
  1658.       if$
  1659.     }
  1660.   if$
  1661.   new.block
  1662.   format.btitle "title" output.check
  1663.   new.clause
  1664.   crossref missing$
  1665.     { format.bvolume output
  1666.       new.clause
  1667.       format.chapter.pages "chapter and pages" output.check
  1668.       new.block
  1669.       format.number.series output
  1670.       new.sentence
  1671.       publisher "publisher" output.check
  1672.       address new.clause.checka
  1673.       address output
  1674.     }
  1675.     { format.chapter.pages "chapter and pages" output.check
  1676.       new.block
  1677.       format.book.crossref output.nonnull
  1678.     }
  1679.   if$
  1680.   edition new.clause.checka
  1681.   format.edition output
  1682.   format.date "year" output.check
  1683.   new.block
  1684.   note output
  1685.   fin.entry
  1686. }
  1687.  
  1688. % An incollection is like inbook, but where there is a separate title
  1689. % for the referenced thing (and perhaps an editor for the whole).
  1690. % An incollection may CROSSREF a book.
  1691. %    Required: author, title, booktitle, publisher, year
  1692. %    Optional: editor, volume or number, series, type, chapter, pages,
  1693. %            address, edition, month, note
  1694. % For the NO_TITLE option the title is suppressed, if the chapter or the pages 
  1695. % field is nonempty (H2B).
  1696.  
  1697. FUNCTION {incollection}
  1698. { output.bibitem
  1699.   format.authors "author" output.check
  1700.   new.block
  1701. #if NO_TITLE
  1702.   chapter empty$ pages empty$ and
  1703.     {
  1704. #endif
  1705.       format.title "title" output.check
  1706.       new.block
  1707. #if NO_TITLE
  1708.     }
  1709.     'skip$
  1710.   if$
  1711. #endif
  1712.   crossref missing$
  1713.     { format.in.ed.booktitle "booktitle" output.check
  1714.       new.clause
  1715.       format.bvolume output
  1716.       new.clause
  1717.       format.number.series output
  1718.       new.clause
  1719.       format.chapter.pages output
  1720.       new.sentence
  1721.       publisher "publisher" output.check
  1722.       address new.clause.checka
  1723.       address output
  1724.       edition new.clause.checka
  1725.       format.edition output
  1726.       format.date "year" output.check
  1727.     }
  1728.     { format.incoll.inproc.crossref output.nonnull
  1729.       new.clause
  1730.       format.chapter.pages output
  1731.     }
  1732.   if$
  1733.   new.block
  1734.   note output
  1735.   fin.entry
  1736. }
  1737.  
  1738. % An inproceedings is an article in a conference proceedings, and it may
  1739. % CROSSREF a proceedings.  If there's no address field, the month (& year)
  1740. % will appear just before note.
  1741. %    Required: author, title, booktitle, year
  1742. %    Optional: editor, volume or number, series, pages, address, month,
  1743. %            organization, publisher, note
  1744. % For the NO_TITLE option the title is suppressed, if the pages field is 
  1745. % nonempty (H2B).
  1746.  
  1747. FUNCTION {inproceedings}
  1748. { output.bibitem
  1749.   format.authors "author" output.check
  1750.   new.block
  1751. #if NO_TITLE
  1752.   pages empty$
  1753.     {
  1754. #endif
  1755.       format.title "title" output.check
  1756.       new.block
  1757. #if NO_TITLE
  1758.     }
  1759.     'skip$
  1760.   if$
  1761. #endif
  1762.   crossref missing$
  1763.     { format.in.ed.booktitle "booktitle" output.check
  1764.       volume new.clause.checka
  1765.       format.bvolume output
  1766.       number series new.clause.checkb
  1767.       format.number.series output
  1768.       pages new.clause.checka
  1769.       format.pages output
  1770.       address empty$
  1771.     { organization publisher new.sentence.checkb
  1772.       organization output
  1773.           publisher new.clause.checka
  1774.       publisher output
  1775.       format.date "year" output.check
  1776.     }
  1777.     { new.clause
  1778.       address output.nonnull
  1779.       format.date "year" output.check
  1780.       new.sentence
  1781.       organization output
  1782.           new.clause
  1783.       publisher output
  1784.     }
  1785.       if$
  1786.     }
  1787.     { format.incoll.inproc.crossref output.nonnull
  1788.       new.clause
  1789.       format.pages output
  1790.     }
  1791.   if$
  1792.   new.block
  1793.   note output
  1794.   fin.entry
  1795. }
  1796.  
  1797. % The conference function is included for Scribe compatibility.
  1798.  
  1799. FUNCTION {conference} { inproceedings }
  1800.  
  1801. % A manual is technical documentation.
  1802. %    Required: title
  1803. %    Optional: author, organization, address, edition, month, year, note
  1804.  
  1805. FUNCTION {manual}
  1806. { output.bibitem
  1807.   author empty$
  1808.     { organization empty$
  1809.     'skip$
  1810.     { organization output.nonnull
  1811.           new.clause
  1812.       address output
  1813.     }
  1814.       if$
  1815.     }
  1816.     { format.authors output.nonnull }
  1817.   if$
  1818.   new.block
  1819.   format.btitle "title" output.check
  1820.   author empty$
  1821.     { organization empty$
  1822.     { address new.block.checka
  1823.       address output
  1824.     }
  1825.     'skip$
  1826.       if$
  1827.     }
  1828.     { organization address new.block.checkb
  1829.       organization output
  1830.       address new.clause.checka
  1831.       address output
  1832.     }
  1833.   if$
  1834.   edition new.clause.checka
  1835.   format.edition output
  1836.   format.date output
  1837.   new.block
  1838.   note output
  1839.   fin.entry
  1840. }
  1841.  
  1842. % A mastersthesis is a Master's thesis.
  1843. %    Required: author, title, school, year
  1844. %    Optional: type, address, month, note
  1845.  
  1846. FUNCTION {mastersthesis}
  1847. { output.bibitem
  1848.   format.authors "author" output.check
  1849.   new.block
  1850.   format.title "title" output.check
  1851.   new.block
  1852.   "\abphrase{17}" format.thesis.type output.nonnull    %H2B
  1853.   new.clause
  1854.   school "school" output.check
  1855.   address new.clause.checka
  1856.   address output
  1857.   format.date "year" output.check
  1858.   new.block
  1859.   note output
  1860.   fin.entry
  1861. }
  1862.  
  1863. % A misc is something that doesn't fit elsewhere.
  1864. %    Required: at least one of the `optional' fields
  1865. %    Optional: author, title, howpublished, month, year, note
  1866.  
  1867. FUNCTION {misc}
  1868. { output.bibitem
  1869.   format.authors output
  1870.   title howpublished new.block.checkb
  1871.   format.title output
  1872.   howpublished new.block.checka
  1873.   howpublished output
  1874.   format.date output
  1875.   new.block
  1876.   note output
  1877.   fin.entry
  1878.   empty.misc.check
  1879. }
  1880.  
  1881. % A phdthesis is like a mastersthesis.
  1882. %    Required: author, title, school, year
  1883. %    Optional: type, address, month, note
  1884.  
  1885. FUNCTION {phdthesis}
  1886. { output.bibitem
  1887.   format.authors "author" output.check
  1888.   new.block
  1889.   format.btitle "title" output.check
  1890.   new.block
  1891.   "\abphrase{18}" format.thesis.type output.nonnull    %H2B
  1892.   new.clause
  1893.   school "school" output.check
  1894.   address new.clause.checka
  1895.   address output
  1896.   format.date "year" output.check
  1897.   new.block
  1898.   note output
  1899.   fin.entry
  1900. }
  1901.  
  1902. % A proceedings is a conference proceedings.
  1903. % If there is an organization but no editor field, the organization will
  1904. % appear as the first optional field (we try to make the first block nonempty);
  1905. % if there's no address field, the month (& year) will appear just before note.
  1906. %    Required: title, year
  1907. %    Optional: editor, volume or number, series, address, month,
  1908. %            organization, publisher, note
  1909.  
  1910. FUNCTION {proceedings}
  1911. { output.bibitem
  1912.   editor empty$
  1913.     { organization output }
  1914.     { format.editors output.nonnull }
  1915.   if$
  1916.   new.block
  1917.   format.btitle "title" output.check
  1918.   volume new.clause.checka
  1919.   format.bvolume output
  1920.   number series new.clause.checkb
  1921.   format.number.series output
  1922.   address empty$
  1923.     { editor empty$
  1924.     { publisher new.sentence.checka }
  1925.     { organization publisher new.sentence.checkb
  1926.       organization output
  1927.           publisher new.clause.checka
  1928.     }
  1929.       if$
  1930.       publisher output
  1931.       format.date "year" output.check
  1932.     }
  1933.     { new.clause
  1934.       address output.nonnull
  1935.       format.date "year" output.check
  1936.       new.sentence
  1937.       editor empty$
  1938.     'skip$
  1939.     { organization output
  1940.       new.clause
  1941.     }
  1942.       if$
  1943.       publisher output
  1944.     }
  1945.   if$
  1946.   new.block
  1947.   note output
  1948.   fin.entry
  1949. }
  1950.  
  1951. % A techreport is a technical report.
  1952. %    Required: author, title, institution, year
  1953. %    Optional: type, number, address, month, note
  1954. % For the NO_TITLE option the title is suppressed, if the number field is 
  1955. % nonempty (H2B).
  1956.  
  1957. FUNCTION {techreport}
  1958. { output.bibitem
  1959.   format.authors "author" output.check
  1960.   new.block
  1961. #if NO_TITLE
  1962.   number empty$
  1963.     {
  1964. #endif
  1965.       format.title "title" output.check
  1966.       new.block
  1967. #if NO_TITLE
  1968.     }
  1969.     'skip$
  1970.   if$
  1971. #endif
  1972.   format.tr.number output.nonnull
  1973.   new.clause
  1974.   institution "institution" output.check
  1975.   address new.clause.checka
  1976.   address output
  1977.   format.date "year" output.check
  1978.   new.block
  1979.   note output
  1980.   fin.entry
  1981. }
  1982.  
  1983. % An unpublished is something that hasn't been published.
  1984. %    Required: author, title, note
  1985. %    Optional: month, year
  1986.  
  1987. FUNCTION {unpublished}
  1988. { output.bibitem
  1989.   format.authors "author" output.check
  1990.   new.block
  1991.   format.title "title" output.check
  1992.   new.block
  1993.   note "note" output.check
  1994.   format.date output
  1995.   fin.entry
  1996. }
  1997.  
  1998. % We use entry type `misc' for an unknown type; BibTeX gives a warning.
  1999.  
  2000. FUNCTION {default.type} { misc }
  2001.  
  2002. % Here are macros for common things that may vary from style to style.
  2003. % Users are encouraged to use these macros.
  2004. %
  2005. % Months are either written out in full or abbreviated
  2006. %
  2007. % The macros for the month names now expand to TeX macros, so they are 
  2008. % adaptable too. Thus no conditional MONTH_FULL is needed anymore (H2B).
  2009. %
  2010. % The \abmonth macro should be defined by the user as something like:
  2011. %   \def\abmonth#1{\ifcase#1\or January\or February\or March\or April\or May\or 
  2012. %     June\or July\or August\or September\or October\or November\or December\fi}
  2013.  
  2014. MACRO {jan} {"\abmonth{1}"}
  2015.  
  2016. MACRO {feb} {"\abmonth{2}"}
  2017.  
  2018. MACRO {mar} {"\abmonth{3}"}
  2019.  
  2020. MACRO {apr} {"\abmonth{4}"}
  2021.  
  2022. MACRO {may} {"\abmonth{5}"}
  2023.  
  2024. MACRO {jun} {"\abmonth{6}"}
  2025.  
  2026. MACRO {jul} {"\abmonth{7}"}
  2027.  
  2028. MACRO {aug} {"\abmonth{8}"}
  2029.  
  2030. MACRO {sep} {"\abmonth{9}"}
  2031.  
  2032. MACRO {oct} {"\abmonth{10}"}
  2033.  
  2034. MACRO {nov} {"\abmonth{11}"}
  2035.  
  2036. MACRO {dec} {"\abmonth{12}"}
  2037.  
  2038. % The next ten macros are provided for edition numbers. For higher numbers the 
  2039. % \abedition command should be extended by the user and called directly or---
  2040. % better---via @STRING declarations in the BIB files. The \abedition command 
  2041. % to be defined by the user is, e.g.:
  2042. %   \def\abedition#1{\ifcase#1\or First\or Second\or Third\or Fourth\or Fifth\or 
  2043. %     Sixth\or Seventh\or Eighth\or Ninth\or Tenth\else?\fi}
  2044.  
  2045. MACRO {first}   {"\abedition{1}"}
  2046.  
  2047. MACRO {second}  {"\abedition{2}"}
  2048.  
  2049. MACRO {third}   {"\abedition{3}"}
  2050.  
  2051. MACRO {fourth}  {"\abedition{4}"}
  2052.  
  2053. MACRO {fifth}   {"\abedition{5}"}
  2054.  
  2055. MACRO {sixth}   {"\abedition{6}"}
  2056.  
  2057. MACRO {seventh} {"\abedition{7}"}
  2058.  
  2059. MACRO {eighth}  {"\abedition{8}"}
  2060.  
  2061. MACRO {ninth}   {"\abedition{9}"}
  2062.  
  2063. MACRO {tenth}   {"\abedition{10}"}
  2064.  
  2065. % Finally, some macros are defined to re-dedicate the CHAPTER field via the 
  2066. % TYPE field. An appropriate \abchapter command were:
  2067. %    \def\abchapter#1{\ifcase#1Section\or Paragraph\or Appendix\or Part\fi}
  2068.  
  2069. MACRO {section}   {"\abchapter{0}"}
  2070.  
  2071. MACRO {paragraph} {"\abchapter{1}"}
  2072.  
  2073. MACRO {appendix}  {"\abchapter{2}"}
  2074.  
  2075. MACRO {part}      {"\abchapter{3}"}
  2076.  
  2077. % Journals are either written out in full or abbreviated;
  2078. % the abbreviations are like those found in ACM publications.
  2079. %
  2080. % To get a completely different set of abbreviations, it may be best to make
  2081. % a separate .bib file with nothing but those abbreviations; users could then
  2082. % include that file name as the first argument to the \bibliography command.
  2083. %
  2084. % All journal macros were commented off, because the set applies only to a 
  2085. % very special field of sciences; so the hint in the previous paragraph 
  2086. % becomes mandatory (H2B).
  2087.  
  2088. % #if JOUR_FULL
  2089. % MACRO {acmcs} {"ACM Computing Surveys"}
  2090. % MACRO {acta} {"Acta Informatica"}
  2091. % MACRO {cacm} {"Communications of the ACM"}
  2092. % MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  2093. % MACRO {ibmsj} {"IBM Systems Journal"}
  2094. % MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  2095. % MACRO {ieeetc} {"IEEE Transactions on Computers"}
  2096. % MACRO {ieeetcad}
  2097. %  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  2098. % MACRO {ipl} {"Information Processing Letters"}
  2099. % MACRO {jacm} {"Journal of the ACM"}
  2100. % MACRO {jcss} {"Journal of Computer and System Sciences"}
  2101. % MACRO {scp} {"Science of Computer Programming"}
  2102. % MACRO {sicomp} {"SIAM Journal on Computing"}
  2103. % MACRO {tocs} {"ACM Transactions on Computer Systems"}
  2104. % MACRO {tods} {"ACM Transactions on Database Systems"}
  2105. % MACRO {tog} {"ACM Transactions on Graphics"}
  2106. % MACRO {toms} {"ACM Transactions on Mathematical Software"}
  2107. % MACRO {toois} {"ACM Transactions on Office Information Systems"}
  2108. % MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  2109. % MACRO {tcs} {"Theoretical Computer Science"}
  2110. % #else !JOUR_FULL
  2111. % MACRO {acmcs} {"ACM Comput. Surv."}
  2112. % MACRO {acta} {"Acta Inf."}
  2113. % MACRO {cacm} {"Commun. ACM"}
  2114. % MACRO {ibmjrd} {"IBM J. Res. Dev."}
  2115. % MACRO {ibmsj} {"IBM Syst.~J."}
  2116. % MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  2117. % MACRO {ieeetc} {"IEEE Trans. Comput."}
  2118. % MACRO {ieeetcad}
  2119. %  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  2120. % MACRO {ipl} {"Inf. Process. Lett."}
  2121. % MACRO {jacm} {"J.~ACM"}
  2122. % MACRO {jcss} {"J.~Comput. Syst. Sci."}
  2123. % MACRO {scp} {"Sci. Comput. Programming"}
  2124. % MACRO {sicomp} {"SIAM J. Comput."}
  2125. % MACRO {tocs} {"ACM Trans. Comput. Syst."}
  2126. % MACRO {tods} {"ACM Trans. Database Syst."}
  2127. % MACRO {tog} {"ACM Trans. Gr."}
  2128. % MACRO {toms} {"ACM Trans. Math. Softw."}
  2129. % MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  2130. % MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  2131. % MACRO {tcs} {"Theoretical Comput. Sci."}
  2132. % #endif JOUR_FULL
  2133.  
  2134. % Now we read in the .BIB entries.
  2135.  
  2136. READ
  2137.  
  2138. % The sortify function converts to lower case after purify$ing; it's
  2139. % used in sorting and in computing alphabetic labels after sorting
  2140. %
  2141. % The chop.word(w,len,s) function returns either s or, if the first len
  2142. % letters of s equals w (this comparison is done in the third line of the
  2143. % function's definition), it returns that part of s after w.
  2144.  
  2145. #if SORTED
  2146.  
  2147. FUNCTION {sortify}
  2148. { purify$
  2149.   "l" change.case$
  2150. }
  2151.  
  2152. INTEGERS { len }
  2153.  
  2154. FUNCTION {chop.word}
  2155. { 's :=
  2156.   'len :=
  2157.   s #1 len substring$ =
  2158.     { s len #1 + global.max$ substring$ }
  2159.     's
  2160.   if$
  2161. }
  2162.  
  2163. #else !SORTED
  2164. #if LAB_ALPH
  2165.  
  2166. % We need the chop.word stuff for the dubious unsorted-list-with-labels case.
  2167.  
  2168. INTEGERS { len }
  2169.  
  2170. FUNCTION {chop.word}
  2171. { 's :=
  2172.   'len :=
  2173.   s #1 len substring$ =
  2174.     { s len #1 + global.max$ substring$ }
  2175.     's
  2176.   if$
  2177. }
  2178.  
  2179. #endif LAB_ALPH
  2180. #endif SORTED
  2181.  
  2182. % This long comment applies only to alphabetic labels
  2183. %
  2184. % The format.lab.names function makes a short label by using the initials of
  2185. % the von and Last parts of the names (but if there are more than four names,
  2186. % (i.e., people) it truncates after three and adds a superscripted "+";
  2187. % it also adds such a "+" if the last of multiple authors is "others").
  2188. % If there is only one name, and its von and Last parts combined have just
  2189. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  2190. % we take the first three letters of the last name.  The boolean
  2191. % et.al.char.used tells whether we've used a superscripted "+", so that we
  2192. % know whether to include a LaTeX macro for it.
  2193. %
  2194. % format.lab.names(s) ==
  2195. %  BEGIN
  2196. %    numnames := num.names$(s)
  2197. %    if numnames > 1 then
  2198. %        if numnames > 4 then
  2199. %        namesleft := 3
  2200. %        else
  2201. %        namesleft := numnames
  2202. %        nameptr := 1
  2203. %        nameresult := ""
  2204. %        while namesleft > 0
  2205. %          do
  2206. %        if (name_ptr = numnames) and
  2207. %             format.name$(s, nameptr, "{ff }{vv }{ll}{ jj}") = "others"
  2208. %           then nameresult := nameresult * "{\etalchar{+}}"
  2209. %            et.al.char.used := true
  2210. %           else nameresult := nameresult *
  2211. %                format.name$(s, nameptr, "{v{}}{l{}}")
  2212. %        nameptr := nameptr + 1
  2213. %        namesleft := namesleft - 1
  2214. %          od
  2215. %        if numnames > 4 then
  2216. %        nameresult := nameresult * "{\etalchar{+}}"
  2217. %        et.al.char.used := true
  2218. %    else
  2219. %        t := format.name$(s, 1, "{v{}}{l{}}")
  2220. %        if text.length$(t) < 2 then    % there's just one name-token
  2221. %        nameresult := text.prefix$(format.name$(s,1,"{ll}"),3)
  2222. %        else
  2223. %        nameresult := t
  2224. %        fi
  2225. %    fi
  2226. %    return nameresult
  2227. %  END
  2228. %
  2229. % Exactly what fields we look at in constructing the primary part of the label
  2230. % depends on the entry type; this selectivity (as opposed to, say, always
  2231. % looking at author, then editor, then key) helps ensure that "ignored" fields,
  2232. % as described in the LaTeX book, really are ignored.  Note that MISC is part
  2233. % of the deepest `else' clause in the nested part of calc.label; thus, any
  2234. % unrecognized entry type in the database is handled correctly.
  2235. %
  2236. % There is one auxiliary function for each of the four different sequences of
  2237. % fields we use.  The first of these functions looks at the author field, and
  2238. % then, if necessary, the key field.  The other three functions, which might
  2239. % look at two fields and the key field, are similar, except that the key field
  2240. % takes precedence over the organization field (for labels---not for sorting).
  2241. %
  2242. % The calc.label function calculates the preliminary label of an entry, which
  2243. % is formed by taking three letters of information from the author or editor or
  2244. % key or organization field (depending on the entry type and on what's empty,
  2245. % but ignoring a leading "The " in the organization), and appending the last
  2246. % two characters (digits) of the year. It is an error if the appropriate fields
  2247. % among author, editor, organization, and key are missing, and we use
  2248. % the first three letters of the cite$ in desperation when this happens.
  2249. % The resulting label has the year part, but not the name part, purify$ed
  2250. % (purify$ing the year allows some sorting shenanigans by the user).
  2251. %
  2252. % This function also calculates the version of the label to be used in sorting.
  2253. %
  2254. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  2255. % otherwise identical labels, but we can't calculated those "extra.label"s
  2256. % until after sorting.
  2257. %
  2258. % calc.label ==
  2259. %  BEGIN
  2260. %    if type$ = "book" or "inbook" then
  2261. %        author.editor.key.label
  2262. %    else if type$ = "proceedings" then
  2263. %        editor.key.organization.label
  2264. %    else if type$ = "manual" then
  2265. %        author.key.organization.label
  2266. %    else
  2267. %        author.key.label
  2268. %    fi fi fi
  2269. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  2270. %        % assuming we will also sort, we calculate a sort.label
  2271. %    sort.label := sortify(label), but use the last four, not two, digits
  2272. %  END
  2273.  
  2274. #if LAB_ALPH
  2275.  
  2276. INTEGERS { et.al.char.used }
  2277.  
  2278. FUNCTION {initialize.et.al.char.used}
  2279. { #0 'et.al.char.used :=
  2280. }
  2281.  
  2282. EXECUTE {initialize.et.al.char.used}
  2283.  
  2284. FUNCTION {format.lab.names}
  2285. { 's :=
  2286.   s num.names$ 'numnames :=
  2287.   numnames #1 >
  2288.     { numnames #4 >
  2289.     { #3 'namesleft := }
  2290.     { numnames 'namesleft := }
  2291.       if$
  2292.       #1 'nameptr :=
  2293.       ""
  2294.     { namesleft #0 > }
  2295.     { nameptr numnames =
  2296.         { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  2297.         { "{\etalchar{+}}" *
  2298.           #1 'et.al.char.used :=
  2299.         }
  2300.         { s nameptr "{v{}}{l{}}" format.name$ * }
  2301.           if$
  2302.         }
  2303.         { s nameptr "{v{}}{l{}}" format.name$ * }
  2304.       if$
  2305.       nameptr #1 + 'nameptr :=
  2306.       namesleft #1 - 'namesleft :=
  2307.     }
  2308.       while$
  2309.       numnames #4 >
  2310.     { "{\etalchar{+}}" *
  2311.       #1 'et.al.char.used :=
  2312.     }
  2313.     'skip$
  2314.       if$
  2315.     }
  2316.     { s #1 "{v{}}{l{}}" format.name$
  2317.       duplicate$ text.length$ #2 <
  2318.     { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
  2319.     'skip$
  2320.       if$
  2321.     }
  2322.   if$
  2323. }
  2324.  
  2325. FUNCTION {author.key.label}
  2326. { author empty$
  2327.     { key empty$
  2328. #if SORTED
  2329.     { cite$ #1 #3 substring$ }
  2330. #else !SORTED        % need warning here because we won't give it later
  2331.     { "for label, need author or key in " cite$ * warning$
  2332.       cite$ #1 #3 substring$
  2333.     }
  2334. #endif SORTED
  2335.     { key #3 text.prefix$ }
  2336.       if$
  2337.     }
  2338.     { author format.lab.names }
  2339.   if$
  2340. }
  2341.  
  2342. FUNCTION {author.editor.key.label}
  2343. { author empty$
  2344.     { editor empty$
  2345.     { key empty$
  2346. #if SORTED
  2347.         { cite$ #1 #3 substring$ }
  2348. #else !SORTED        % need warning here because we won't give it later
  2349.         { "for label, need author, editor, or key in " cite$ * warning$
  2350.               cite$ #1 #3 substring$
  2351.         }
  2352. #endif SORTED
  2353.         { key #3 text.prefix$ }
  2354.       if$
  2355.     }
  2356.     { editor format.lab.names }
  2357.       if$
  2358.     }
  2359.     { author format.lab.names }
  2360.   if$
  2361. }
  2362.  
  2363. FUNCTION {author.key.organization.label}
  2364. { author empty$
  2365.     { key empty$
  2366.     { organization empty$
  2367. #if SORTED
  2368.         { cite$ #1 #3 substring$ }
  2369. #else !SORTED        % need warning here because we won't give it later
  2370.         { "for label, need author, key, or organization in " cite$ *
  2371.                                 warning$
  2372.               cite$ #1 #3 substring$
  2373.         }
  2374. #endif SORTED
  2375.         { "The " #4 organization chop.word #3 text.prefix$ }
  2376.       if$
  2377.     }
  2378.     { key #3 text.prefix$ }
  2379.       if$
  2380.     }
  2381.     { author format.lab.names }
  2382.   if$
  2383. }
  2384.  
  2385. FUNCTION {editor.key.organization.label}
  2386. { editor empty$
  2387.     { key empty$
  2388.     { organization empty$
  2389. #if SORTED
  2390.         { cite$ #1 #3 substring$ }
  2391. #else !SORTED        % need warning here because we won't give it later
  2392.         { "for label, need editor, key, or organization in " cite$ *
  2393.                                 warning$
  2394.               cite$ #1 #3 substring$
  2395.         }
  2396. #endif SORTED
  2397.         { "The " #4 organization chop.word #3 text.prefix$ }
  2398.       if$
  2399.     }
  2400.     { key #3 text.prefix$ }
  2401.       if$
  2402.     }
  2403.     { editor format.lab.names }
  2404.   if$
  2405. }
  2406.  
  2407. FUNCTION {calc.label}
  2408. { type$ "book" =
  2409.   type$ "inbook" =
  2410.   or
  2411.     'author.editor.key.label
  2412.     { type$ "proceedings" =
  2413.     'editor.key.organization.label
  2414.     { type$ "manual" =
  2415.         'author.key.organization.label
  2416.         'author.key.label
  2417.       if$
  2418.     }
  2419.       if$
  2420.     }
  2421.   if$
  2422.   duplicate$
  2423.   year field.or.null purify$ #-1 #2 substring$
  2424.   *
  2425.   'label :=
  2426.   year field.or.null purify$ #-1 #4 substring$
  2427.   *
  2428.   sortify 'sort.label :=
  2429. }
  2430.  
  2431. % It doesn't seem like a particularly good idea to use an order-of-citation
  2432. % reference list when using alphabetic labels, but we need to have a
  2433. % special pass to calculate labels when this happens.
  2434.  
  2435. #if !SORTED
  2436.  
  2437. ITERATE {calc.label}
  2438.  
  2439. #endif !SORTED
  2440.  
  2441. #endif LAB_ALPH
  2442.  
  2443. % When sorting, we compute the sortkey by executing "presort" on each entry.
  2444. % The presort key contains a number of "sortify"ed strings, concatenated
  2445. % with multiple blanks between them.  This makes things like "brinch  per"
  2446. % come before "brinch hansen  per".
  2447. %
  2448. % The fields used here are: the sort.label for alphabetic labels (as set by
  2449. % calc.label), followed by the author names (or editor names or organization
  2450. % (with a leading "The " removed) or key field, depending on entry type and on
  2451. % what's empty), followed by year, followed by the first bit of the title
  2452. % (chopping off a leading "The ", "A ", or "An ").
  2453. % Names are formatted: Von Last First Junior.
  2454. % The names within a part will be separated by a single blank
  2455. % (such as "brinch hansen"), two will separate the name parts themselves
  2456. % (except the von and last), three will separate the names,
  2457. % four will separate the names from year (and from label, if alphabetic),
  2458. % and four will separate year from title.
  2459. %
  2460. % The sort.format.names function takes an argument that should be in
  2461. % BibTeX name format, and returns a string containing "   "-separated
  2462. % names in the format described above.  The function is almost the same
  2463. % as format.names.
  2464.  
  2465. #if SORTED
  2466.  
  2467. FUNCTION {sort.format.names}
  2468. { 's :=
  2469.   #1 'nameptr :=
  2470.   ""
  2471.   s num.names$ 'numnames :=
  2472.   numnames 'namesleft :=
  2473.     { namesleft #0 > }
  2474.     { nameptr #1 >
  2475.     { "   " * }
  2476.     'skip$
  2477.       if$
  2478. #if NAME_FULL
  2479.       s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
  2480. #else
  2481.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
  2482. #endif NAME_FULL
  2483.       nameptr numnames = t "others" = and
  2484.     { "et al" * }
  2485.     { t sortify * }
  2486.       if$
  2487.       nameptr #1 + 'nameptr :=
  2488.       namesleft #1 - 'namesleft :=
  2489.     }
  2490.   while$
  2491. }
  2492.  
  2493. % The sort.format.title function returns the argument,
  2494. % but first any leading "A "'s, "An "'s, or "The "'s are removed.
  2495. % The chop.word function uses s, so we need another string variable, t
  2496.  
  2497. FUNCTION {sort.format.title}
  2498. { 't :=
  2499.   "A " #2
  2500.     "An " #3
  2501.       "The " #4 t chop.word
  2502.     chop.word
  2503.   chop.word
  2504.   sortify
  2505.   #1 global.max$ substring$
  2506. }
  2507.  
  2508. % The auxiliary functions here, for the presort function, are analogous to
  2509. % the ones for calc.label; the same comments apply, except that the
  2510. % organization field takes precedence here over the key field.  For sorting
  2511. % purposes, we still remove a leading "The " from the organization field.
  2512.  
  2513. FUNCTION {author.sort}
  2514. { author empty$
  2515.     { key empty$
  2516.     { "to sort, need author or key in " cite$ * warning$
  2517.       ""
  2518.     }
  2519.     { key sortify }
  2520.       if$
  2521.     }
  2522.     { author sort.format.names }
  2523.   if$
  2524. }
  2525.  
  2526. FUNCTION {author.editor.sort}
  2527. { author empty$
  2528.     { editor empty$
  2529.     { key empty$
  2530.         { "to sort, need author, editor, or key in " cite$ * warning$
  2531.           ""
  2532.         }
  2533.         { key sortify }
  2534.       if$
  2535.     }
  2536.     { editor sort.format.names }
  2537.       if$
  2538.     }
  2539.     { author sort.format.names }
  2540.   if$
  2541. }
  2542.  
  2543. FUNCTION {author.organization.sort}
  2544. { author empty$
  2545.     { organization empty$
  2546.     { key empty$
  2547.         { "to sort, need author, organization, or key in " cite$ * warning$
  2548.           ""
  2549.         }
  2550.         { key sortify }
  2551.       if$
  2552.     }
  2553.     { "The " #4 organization chop.word sortify }
  2554.       if$
  2555.     }
  2556.     { author sort.format.names }
  2557.   if$
  2558. }
  2559.  
  2560. FUNCTION {editor.organization.sort}
  2561. { editor empty$
  2562.     { organization empty$
  2563.     { key empty$
  2564.         { "to sort, need editor, organization, or key in " cite$ * warning$
  2565.           ""
  2566.         }
  2567.         { key sortify }
  2568.       if$
  2569.     }
  2570.     { "The " #4 organization chop.word sortify }
  2571.       if$
  2572.     }
  2573.     { editor sort.format.names }
  2574.   if$
  2575. }
  2576.  
  2577. % There is a limit, entry.max$, on the length of an entry string variable
  2578. % (which is what its sort.key$ is), so we take at most that many characters
  2579. % of the constructed key, and hope there aren't many references that match
  2580. % to that many characters!
  2581.  
  2582. FUNCTION {presort}
  2583. #if LAB_ALPH
  2584. { calc.label
  2585.   sort.label
  2586.   "    "
  2587.   *
  2588.   type$ "book" =
  2589. #else !LAB_ALPH
  2590. { type$ "book" =
  2591. #endif LAB_ALPH
  2592.   type$ "inbook" =
  2593.   or
  2594.     'author.editor.sort
  2595.     { type$ "proceedings" =
  2596.     'editor.organization.sort
  2597.     { type$ "manual" =
  2598.         'author.organization.sort
  2599.         'author.sort
  2600.       if$
  2601.     }
  2602.       if$
  2603.     }
  2604.   if$
  2605. #if LAB_ALPH
  2606.   *
  2607. #endif LAB_ALPH
  2608.   "    "
  2609.   *
  2610.   year field.or.null sortify
  2611.   *
  2612.   "    "
  2613.   *
  2614.   title field.or.null
  2615.   sort.format.title
  2616.   *
  2617.   #1 entry.max$ substring$
  2618.   'sort.key$ :=
  2619. }
  2620.  
  2621. ITERATE {presort}
  2622.  
  2623. % And now we can sort
  2624.  
  2625. SORT
  2626.  
  2627. #endif SORTED
  2628.  
  2629. % This long comment applies only to alphabetic labels, when sorted
  2630. %
  2631. % Now comes the final computation for alphabetic labels, putting in the 'a's
  2632. % and 'b's and so forth if required.  This involves two passes: a forward
  2633. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  2634. % to put in the 'a's (we don't want to put in 'a's unless we know there
  2635. % are 'b's).
  2636. % We have to keep track of the longest (in width$ terms) label, for use
  2637. % by the "thebibliography" environment.
  2638. %
  2639. % VAR: longest.label, last.sort.label, next.extra: string
  2640. %      longest.label.width, last.extra.num: integer
  2641. %
  2642. % initialize.longest.label ==
  2643. %  BEGIN
  2644. %    longest.label := ""
  2645. %    last.sort.label := int.to.chr$(0)
  2646. %    next.extra := ""
  2647. %    longest.label.width := 0
  2648. %    last.extra.num := 0
  2649. %  END
  2650. %
  2651. % forward.pass ==
  2652. %  BEGIN
  2653. %    if last.sort.label = sort.label then
  2654. %        last.extra.num := last.extra.num + 1
  2655. %        extra.label := int.to.chr$(last.extra.num)
  2656. %    else
  2657. %        last.extra.num := chr.to.int$("a")
  2658. %        extra.label := ""
  2659. %        last.sort.label := sort.label
  2660. %    fi
  2661. %  END
  2662. %
  2663. % reverse.pass ==
  2664. %  BEGIN
  2665. %    if next.extra = "b" then
  2666. %        extra.label := "a"
  2667. %    fi
  2668. %    label := label * extra.label
  2669. %    if width$(label) > longest.label.width then
  2670. %        longest.label := label
  2671. %        longest.label.width := width$(label)
  2672. %    fi
  2673. %    next.extra := extra.label
  2674. %  END
  2675.  
  2676. #if LAB_ALPH
  2677.  
  2678. #if SORTED
  2679.  
  2680. STRINGS { longest.label last.sort.label next.extra }
  2681.  
  2682. INTEGERS { longest.label.width last.extra.num }
  2683.  
  2684. FUNCTION {initialize.longest.label}
  2685. { "" 'longest.label :=
  2686.   #0 int.to.chr$ 'last.sort.label :=
  2687.   "" 'next.extra :=
  2688.   #0 'longest.label.width :=
  2689.   #0 'last.extra.num :=
  2690. }
  2691.  
  2692. FUNCTION {forward.pass}
  2693. { last.sort.label sort.label =
  2694.     { last.extra.num #1 + 'last.extra.num :=
  2695.       last.extra.num int.to.chr$ 'extra.label :=
  2696.     }
  2697.     { "a" chr.to.int$ 'last.extra.num :=
  2698.       "" 'extra.label :=
  2699.       sort.label 'last.sort.label :=
  2700.     }
  2701.   if$
  2702. }
  2703.  
  2704. FUNCTION {reverse.pass}
  2705. { next.extra "b" =
  2706.     { "a" 'extra.label := }
  2707.     'skip$
  2708.   if$
  2709.   label extra.label * 'label :=
  2710.   label width$ longest.label.width >
  2711.     { label 'longest.label :=
  2712.       label width$ 'longest.label.width :=
  2713.     }
  2714.     'skip$
  2715.   if$
  2716.   extra.label 'next.extra :=
  2717. }
  2718.  
  2719. EXECUTE {initialize.longest.label}
  2720.  
  2721. ITERATE {forward.pass}
  2722.  
  2723. REVERSE {reverse.pass}
  2724.  
  2725. #else !SORTED
  2726.  
  2727. % It still doesn't seem like a good idea to use an order-of-citation
  2728. % reference list when using alphabetic labels, but when this happens we
  2729. % must compute the longest label
  2730.  
  2731. STRINGS { longest.label }
  2732.  
  2733. INTEGERS { longest.label.width }
  2734.  
  2735. FUNCTION {initialize.longest.label}
  2736. { "" 'longest.label :=
  2737.   #0 'longest.label.width :=
  2738. }
  2739.  
  2740. FUNCTION {longest.label.pass}
  2741. { label width$ longest.label.width >
  2742.     { label 'longest.label :=
  2743.       label width$ 'longest.label.width :=
  2744.     }
  2745.     'skip$
  2746.   if$
  2747. }
  2748.  
  2749. EXECUTE {initialize.longest.label}
  2750.  
  2751. ITERATE {longest.label.pass}
  2752.  
  2753. #endif SORTED
  2754.  
  2755. #else !LAB_ALPH
  2756.  
  2757. % Now comes the computation for numeric labels.
  2758. % We use either the sorted order or original order.
  2759. % We still have to keep track of the longest (in width$ terms) label, for use
  2760. % by the "thebibliography" environment.
  2761.  
  2762. STRINGS { longest.label }
  2763.  
  2764. INTEGERS { number.label longest.label.width }
  2765.  
  2766. FUNCTION {initialize.longest.label}
  2767. { "" 'longest.label :=
  2768.   #1 'number.label :=
  2769.   #0 'longest.label.width :=
  2770. }
  2771.  
  2772. FUNCTION {longest.label.pass}
  2773. { number.label int.to.str$ 'label :=
  2774.   number.label #1 + 'number.label :=
  2775.   label width$ longest.label.width >
  2776.     { label 'longest.label :=
  2777.       label width$ 'longest.label.width :=
  2778.     }
  2779.     'skip$
  2780.   if$
  2781. }
  2782.  
  2783. EXECUTE {initialize.longest.label}
  2784.  
  2785. ITERATE {longest.label.pass}
  2786.  
  2787. #endif LAB_ALPH
  2788.  
  2789. % Now we're ready to start writing the .BBL file.
  2790. % We begin, if necessary, with a LaTeX macro for unnamed names in an alphabetic
  2791. % label; next comes stuff from the `preamble' command in the database files.
  2792. % Then we give an incantation containing the command
  2793. %     \begin{thebibliography}{...}
  2794. % where the `...' is the longest label.
  2795. %
  2796. % We also call init.state.consts, for use by the output routines.
  2797. %
  2798. % At first a TeX definition is output, that makes user commands able to 
  2799. % distinguish between a ``full'' and an ``abbreviated'' style (H2B).
  2800.  
  2801. FUNCTION {begin.bib}
  2802. {
  2803. #if MONTH_FULL
  2804.   "\newif\ifabfull\abfulltrue" write$ newline$
  2805. #else
  2806.   "\newif\ifabfull\abfullfalse" write$ newline$
  2807. #endif
  2808. #if LAB_ALPH
  2809.   et.al.char.used
  2810.     { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
  2811.     'skip$
  2812.   if$
  2813. #endif LAB_ALPH
  2814.   preamble$ empty$
  2815.     'skip$
  2816.     { preamble$ write$ newline$ }
  2817.   if$
  2818.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  2819. }
  2820.  
  2821. EXECUTE {begin.bib}
  2822.  
  2823. EXECUTE {init.state.consts}
  2824.  
  2825. % Now we produce the output for all the entries
  2826.  
  2827. ITERATE {call.type$}
  2828.  
  2829. % Finally, we finish up by writing the `\end{thebibliography}' command.
  2830.  
  2831. FUNCTION {end.bib}
  2832. { newline$
  2833.   "\end{thebibliography}" write$ newline$
  2834. }
  2835.  
  2836. EXECUTE {end.bib}
  2837.